Integration
Easily integrate Tiny API into your projects
Integrating Tiny API into your projects is a straightforward process. Follow these simple steps, and you'll have the power of Tiny API at your fingertips.
Step 1: Sign Up and Get Your API Key
To get started with Tiny API, you'll first need to sign up for an account on our website. Once you've signed up, you'll receive an API key, which you'll need to include in your API requests for authentication.
Step 2: Choose Your API
Next, you'll need to choose the API you want to integrate into your project. Explore our extensive catalog of APIs, and find the one that best suits your needs. Make sure to familiarize yourself with the API documentation, which includes important information on the available endpoints, request parameters, and response formats.
Step 3: Make API Requests
With your API key and chosen API in hand, you're now ready to start making API requests. You can use any programming language or tool that supports HTTP requests to make calls to the Tiny API endpoints. Remember to include your API key in the request headers for authentication.
Example API Request
Here's a sample API request using Python and the popular requests
library:
import requests
api_key = "your_api_key"
url = "https://api.tinyapi.co/v1/your-chosen-api/your-api-endpoint"
headers = {"Authorization": f"Api-Key {api_key}"}
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
print(data)
else:
print(f"Error: {response.status_code}")
Language
Java
To make API requests using Java, you can use the java.net package or a library like OkHttp. Here's an example using OkHttp:
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
public class ApiRequest {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.tinyapi.co/your-api-endpoint")
.header("Authorization", "Api-Key YOUR_API_KEY")
.build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
System.out.println(response.body().string());
} else {
System.out.println("Error: " + response.code());
}
}
}
}
jQuery
You can use the $.ajax()
method to make API requests using jQuery:
$.ajax({
url: 'https://api.tinyapi.co/v1/your-chosen-api/your-api-endpoint',
headers: {
'Authorization': 'Api-Key YOUR_API_KEY'
},
success: function(response) {
console.log(response);
},
error: function(error) {
console.error(error);
}
});
Nest.js
In Nest.js, you can use the HttpModule or a library like axios to make API requests. Here's an example using the HttpModule:
import { HttpModule, HttpService } from '@nestjs/common';
@Injectable()
export class ApiService {
constructor(private httpService: HttpService) {}
async fetchData() {
const response = await this.httpService.get('https://api.tinyapi.co/your-api-endpoint', {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY'
}
}).toPromise();
return response.data;
}
}
Node.js
To make API requests using Node.js, you can use the built-in http
module or popular libraries like axios
or fetch
. Here's an example using axios
:
const axios = require('axios');
axios.get('https://api.tinyapi.co/v1/your-chosen-api/your-api-endpoint', {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY'
}
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
PHP
To make API requests using PHP, you can use the built-in cURL functions or a library like GuzzleHttp. Here's an example using GuzzleHttp:
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$response = $client->get('https://api.tinyapi.co/your-api-endpoint', [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY'
]
]);
if ($response->getStatusCode() == 200) {
echo json_encode(json_decode((string) $response->getBody()));
} else {
echo "Error: {$response->getStatusCode()}";
}
Python
Here's a sample API request using Python and the popular requests
library:
import requests
api_key = "your_api_key"
url = "https://api.tinyapi.co/v1/your-chosen-api/your-api-endpoint"
headers = {"Authorization": f"Api-Key {api_key}"}
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
print(data)
else:
print(f"Error: {response.status_code}")
React
In React, you can use the fetch API or a library like axios to make API requests. Here's an example using the fetch API:
fetch('https://api.tinyapi.co/v1/your-chosen-api/your-api-endpoint', {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY'
}
})
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch(error => {
console.error(error);
});
Ruby
In Ruby, you can use the net/http library or a gem like httparty to make API requests. Here's an example using httparty:
require 'httparty'
response = HTTParty.get('https://api.tinyapi.co/your-api-endpoint',
headers: {
'Authorization' => 'Api-Key YOUR_API_KEY'
}
)
if response.code == 200
puts response.parsed_response
else
puts "Error: #{response.code}"
end
Svelte
In Svelte, you can use the fetch API or a library like axios to make API requests. Here's an example using the fetch API:
fetch('https://api.tinyapi.co/your-api-endpoint', {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY'
}
})
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch(error => {
console.error(error);
});