Learn how to integrate DevApiHub ApiEndpoint and build amazing projects.
An API (Application Programming Interface) acts as a messenger between two applications. Think of it as a waiter in a restaurant: you (the client) ask for food (data), the waiter (API) takes your request to the kitchen (server), and brings the food back to you.
Retrieve data from server.
Send/Create new data to server.
Update or replace existing data.
Partially update specific data.
Remove data from server.
Same as GET but without response body.
fetch() is a modern JavaScript method used to call an API. It allows you to make network requests to get data without refreshing the page.
// Using Async/Await (Modern Way)
const getExchangeRate = async () => {
try {
const response = await fetch('https://api.devapihub.com/v1/usd-to-bdt');
const data = await response.json();
console.log(data);
} catch (error) {
console.error("Error fetching data:", error);
}
};
getExchangeRate();Common responses you might receive from the API.
| Code | Status | Description |
|---|---|---|
| 200 | OK | Request was successful. |
| 201 | Created | Resource created successfully. |
| 400 | Bad Request | Invalid request parameters. |
| 401 | Unauthorized | Invalid or missing API key. |
| 404 | Not Found | Endpoint not found. |
| 500 | Server Error | Something went wrong on our end. |