Cohorts
  • Discover
  • About Us
  • Blog
  • Patika.dev
  • Web3

REST API

Rest-Api Çalışma Mantığı

Rest-Api Giriş
API Nedir?
Rest-Api Nedir?
REST Prensipleri I
REST Prensipleri II
HTTP Nedir?
HTTP Durum Kodları
HTTP Metotları
JSON Nedir?
JSON-JavaSript-XML
Postman

Star Wars API
TMDB API
Fake API
cURL Kullanımı

Fake API Kullanımı (JSON-SERVER)

Bu pratiğimizde bir Fake (göstermelik) REST API oluşturacağız. Fake REST API oluşturmanın avantajları:

  • Frontend (Ön yüz) tarafı hazır olan bir uygulamayı test etmek isteyebiliriz.
  • Yapmayı düşündüğümüz bir Backend (Arka yüz) çalışması için bir prototip oluşturmak isteyebiliriz.
  • Postman gibi bir API platformunda farklı HTTP metotlarına ait istekler gerçekleştirmek isteyebiliriz.

FAKE REST API oluşturmak için json-server npm paketinden faydalanacağız, bunun için bilgisayarımızda JavaScript çalışma Node.js ( https://nodejs.org/en/) uygulamasının yüklü olması gerekmektedir. Başlangıç olarak

npm init

komutu ile package.json dosyası oluşturacağız.

npm i json-server

komutu ile json-server paketini indiriyoruz.

API için kullanacağımız örnek employees.json dosyası : https://github.com/Kodluyoruz/taskforce/blob/main/rest/FakeAPI/files/employees.json . Bu dosyayı oluşturacağımız api klasörünün içerisinde yerleştiriyoruz.

Projemizde bulunan package.json dosyası içerisindeki script bölümünü aşağıdaki şekilde güncelliyoruz.

  "scripts": {
    "start:server": "json-server --watch api/employees.json"
  },

Bu sayede aşağıdaki komut ile FAKE API çalışmaya başlayacak.

npm run start:server

Örnek İstekler

GET ALL EMPLOYEES - GET : http://localhost:3000/employees
GET AN EMPLOYEE DETAILS - GET : http://localhost:3000/employees/:employee_id
EMPLOYEES - ROLES RELATION - GET : http://localhost:3000/employees?_expand=role
ADD AN EMPLOYEE - POST : http://localhost:3000/employees
UPDATE AN EMPLOYEE - PATCH(PUT) : http://localhost:3000/employees/:employee_id
DELETE AN EMPLOYEE - DELETE : http://localhost:3000/employees/:employee_id


Daha Fazlası İçin

  • JSON-SERVER GITHUB
  • Node.js Dokümantasyon
Previous
Next

Lesson discussion

Swap insights and ask questions about “REST API”.

Enroll to participate
Start the course to unlock the discussion. Enrolling helps us keep conversations relevant to learners.
Cohorts
WebsiteDiscoverBlogPatika.devRise In
CoursesCircleRustSoliditySolanaWeb3 FundamentalsBlockchain Basics
CompanyAbout UsTerms of UsePrivacy PolicyGDPR NoticeCookies
Don't miss any update!

Disclaimer: The information, programs, and events provided on https://cohorts.patika.dev is strictly for upskilling and networking purposes related to the technical infrastructure of blockchain platforms. We do not provide financial or investment advice, nor do we make any representations regarding the value, profitability, or future price of any blockchain or cryptocurrency. Users are encouraged to conduct their own research and consult with licensed financial professionals before engaging in any investment activities. https://cohorts.patika.dev disclaims any responsibility for financial decisions made by users based on the information provided here.

© 2026 Cohorts, All rights reserved