> For the complete documentation index, see [llms.txt](https://docs.layraweb.com.tr/merhaba/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.layraweb.com.tr/merhaba/php-tarafi/konular/api-entegrasyonlari/api-istekleri.md).

# API İstekleri

API (Application Programming Interface), uygulamalar arasında veri alışverişi yapabilmek için kullanılan bir ara yüzdür. PHP, diğer uygulamaların verilerine API istekleri yaparak bu verileri alabilir ve işleyebilir.

API istekleri, PHP'nin `curl` işlevini kullanarak veya `file_get_contents()` işleviyle gerçekleştirilebilir. `curl` işlevi, farklı HTTP metotlarını (GET, POST, PUT, DELETE vb.) kullanarak URL'ye istek göndermek ve yanıt almak için kullanılır.

Örneğin, bir API'ye GET isteği göndererek JSON verilerini alabilirsiniz:

```php
phpCopy code$url = 'https://jsonplaceholder.typicode.com/todos';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
$todo_list = json_decode($response, true);
```

Yukarıdaki örnekte, `jsonplaceholder.typicode.com` API'sine bir GET isteği gönderilir ve alınan yanıt bir değişkende depolanır. `json_decode()` işlevi, JSON verilerini PHP dizisine dönüştürür.

Ayrıca, `file_get_contents()` işlevi de bir API'ye GET isteği göndermek için kullanılabilir:

```php
phpCopy code$url = 'https://jsonplaceholder.typicode.com/todos';
$response = file_get_contents($url);
$todo_list = json_decode($response, true);
```

Yukarıdaki örnekte, `file_get_contents()` işlevi kullanılarak JSON verileri alınır ve `json_decode()` işlevi kullanılarak PHP dizisine dönüştürülür.

API istekleri, HTTP başlıklarını (headers) belirtmek, parametreleri (query parameters veya request body) göndermek, belirli bir HTTP metodu kullanmak ve diğer HTTP ayarlarını belirlemek için `curl_setopt()` işlevi kullanılarak özelleştirilebilir.

API'ler, farklı veri türlerini (JSON, XML, CSV vb.) ve veri formatlarını (REST, SOAP vb.) kullanabilirler. API'ler, çeşitli kaynaklardan (web siteleri, veritabanları, diğer uygulamalar vb.) verileri alabilirler ve bu verileri farklı uygulamalar arasında paylaşabilirler.

API'leri kullanarak, PHP uygulamaları farklı veri kaynaklarına erişebilir, verileri alabilir ve bu verileri kullanarak farklı işlemler yapabilirler.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.layraweb.com.tr/merhaba/php-tarafi/konular/api-entegrasyonlari/api-istekleri.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
