Skip to content

Getting Started

Depending on your needs and what you want to build, you can use TurkiyeAPI in different ways. This guide explains how to start using the API step-by-step.

If you're working on a personal or non-critical project, you can use the API directly via turkiyeapi.dev. However, if you want more control and customization—especially for commercial use—we recommend running the API on your own server. This approach offers better security and scalability for your project.

Fair Use Policy

TurkiyeAPI is available for everyone and does not require authentication. That said, we kindly ask you to use the API fairly and responsibly. Abusing the service, making excessive requests, or intentionally disrupting access can negatively affect other users and degrade the overall quality of service.

API Rate Limiting Policy

  • Each IP address is limited to 150 requests per 15 minutes.
  • If you exceed this limit, you’ll receive a 429 - Too Many Requests error.
  • You can resume making requests once the cooldown period has passed.
plaintext
Too many requests from this IP, please try again in 15 minutes!

Staying within these limits helps ensure that everyone can benefit from the service.

Using the API

url
https://turkiyeapi.dev/api/v1/

The URL above is the main entry point to the API. You can use it to interact with the service and retrieve data.

Here are a few code examples that demonstrate how to make a GET request:

bash
curl https://turkiyeapi.dev/api/v1/
javascript
fetch('https://turkiyeapi.dev/api/v1/')
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error('Error fetching data:', error));

WARNING

The curl command may not work in Windows PowerShell. In that case, use Invoke-WebRequest instead:

powershell
Invoke-WebRequest -Uri 'https://turkiyeapi.dev/api/v1/' -Method GET

If your request is successful, the API will return a response like this, with status code 200:

json
{
  "status": "OK",
  "message": "Welcome to the TurkiyeAPI"
}

Running the API Locally

To run the API locally, you need to have Node.js and npm installed.

Follow these steps to set up the API on your own server:

  1. Choose a directory and navigate into it:
bash
cd /path/to/your/directory
  1. Clone the source code from GitHub:
bash
git clone https://github.com/ubeydeozdmr/turkiye-api.git
  1. Install the project dependencies:
bash
cd turkiye-api
npm install
  1. By default, TurkiyeAPI runs on port 8181. To start the API:
bash
npm start
  1. Once the API is running, you’ll see an output like this in your terminal:
bash
TurkiyeAPI is running at http://localhost:8181
  1. You can now access the API via your browser or an API testing tool:
url
http://localhost:8181/api/v1/

Environment Variables

You can customize certain aspects of the API using environment variables. These variables allow you to modify the behavior and configuration of the API.

For example, to change the port number or the environment mode, set the following:

env
PORT=8181
NODE_ENV=development

You can set environment variables in the terminal like this:

bash
# Set environment variables and start the API
set PORT=8181 && set NODE_ENV=development && npm start
bash
# Set environment variables and start the API
export PORT=8181 && export NODE_ENV=development && npm start

Alternatively, you can create a .env file in the project root and add the variables there.