API
Development
Makoto Evarolo
Ivan De La Pena
Regil Tagalogon
Charles Xander Cullog
Jude Thaddeus Gabaisen
API
An API (Application Programming
Interface) is a set of rules that allows
different software applications to
communicate with each other. APIs
enable integration between systems,
making data and functionality accessible
without exposing internal code.
Why APIs Are Important?
Interoperability – APIs connect different systems and platforms.
Efficiency – They reduce redundancy by reusing services.
Scalability – APIs enable microservices architecture and
modular design.
Automation – Systems can communicate and exchange data
automatically.
Key Concepts of API
Development
1.Endpoints
These are specific URLs where an API can be accessed. Ex:
GET https://api.example.com/users
2.HTTP Methods
GET – Retrieve data
POST – Create new data
PUT – Update existing data
DELETE – Remove data
3.Authentication & Authorization
API Keys – A simple token for access control.
OAuth 2.0 – Secure token-based authentication.
JWT (JSON Web Token) – A compact and secure token format.
4.Response Codes (HTTP Status Codes)
200 OK – Successful request
201 Created – Successfully added data
400 Bad Request – Invalid request parameters
401 Unauthorized – Authentication failed
404 Not Found – Endpoint does not exist
500 Internal Server Error – Unexpected failure
Developing and Consuming
RESTful APIs
1. REST (Representational State Transfer) is a common architecture for
APIs that follows these principles:
Stateless – Each request is independent.
Client-Server Architecture – The frontend (client) and backend
(server) are separate.
Cacheable – Responses can be cached for performance.
Steps to Develop a REST API
Design the API (Define endpoints, request/response structure).
Choose a Framework (Node.js with Express, Python with
Flask/Django, etc.).
Implement the API (Write controllers, models, and routes).
Test the API (Using Postman or automated tests).
Deploy (Host API on a cloud service like AWS, Azure, or Heroku).
sample code
JavaScript Fetch API
Fetch is based on async and await.
fetch(file)
.then(x => x.text())
.then(y => myDisplay(y));
sample code
Python (Requests Library)
requests.get(): Sends a GET request to the specified URL.
requests.post(): Creates a POST request, often to submit data to a
server.
requests.put(): Sends a PUT request, updating a resource on the
server.
requests.delete(): The DELETE request deletes a resource on the
server.
Best Practices for API Design and
Design Principles
Security
Use consistent naming conventions (camelCase or snake_case).
Version your API (/api/v1/ to avoid breaking changes).
Use pagination for large datasets (?page=1&limit=10).
Implement rate limiting to prevent abuse.
Security Best Practices
Always use HTTPS for secure communication.
Validate user input to prevent SQL injection and XSS attacks.
Implement authentication (OAuth, JWT).
Log API activity to monitor usage and detect threats.
That’s all arigathanks