Some apis la baiatu
1 min
aici gen esti ma???
alte commenturili
Get Cakes
Get a cake by its ID
GET
https://api.cakes.com
Body Parameters
- idstringrequiredDescription
- namestring
curl
curl --location --request GET 'https://api.cakes.com' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"id": "String",
"name": "String"
}'nodejs
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://api.cakes.com',
'headers': {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"id": "String",
"name": "String"
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
javascript
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"id": "String",
"name": "String"
});
var requestOptions = {
method: 'GET',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.cakes.com", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));python
import requests
import json
url = "https://api.cakes.com"
payload = json.dumps({
"id": "String",
"name": "String"
})
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.cakes.com")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"id": "String",
"name": "String"
})
response = https.request(request)
puts response.read_body
200
{
"name": "Cake's name",
}404
{
"message": "Ain't no cake like that."
}