What Is An API ?
- Application Program Interface
- APIs Are Everywhere
- Contract provided by one piece of software to another software
- Structured request and response
What Is REST ?
- Representational State Transfer
- Architecture style for designing networked applications
- Relies on a stateless, client-server protocol, almost always HTTP
- Treats server objects as resources that can be created or destroyed
- Can be used by virtually any programming language
HTTP Methods
- GET: Retrieve data from a specified resource
- POST: Submit data to be processed to a specified resource
- PUT: Update a specified resource
- DELETE: Delete a specified resource
- HEAD: Same as get but does not return a body
- OPTIONS: Returns the supported HTTP methods
- PATCH: Update partial resources
Endpoints
The URI/URL where api/service can be accessed by a client application
- GET: https://khmerside.xyz/api/users
- GET: https://khmerside.xyz/api/users/1 OR
https://khmerside.xyz/api/users/details/1
- POST: https://khmerside.xyz/api/users
- PUT: https://khmerside.xyz/api/users/1 OR
https://khmerside.xyz/api/users/update/1
- DELETE: https://khmerside.xyz/api/users/1 OR
https://khmerside.xyz/api/users/delete/1
Authentication
Some API's require authentication to use their service. This could be free or paid
curl -H "Authorization:token OAUTH-TOKEN" https://api.github.com
curl https://api.github.com/?access_token=OAUTH-TOKEN
curl
'https://api.github.com/users/whatever?client_id=xxxx&client_secret=yyyyy'
Try to use postman for api testing
Now I will test api to call github user api
Good post. Thank you for sharing.
ReplyDeleteMoviebox app for android