Code Samples #
Copy
curl --request GET \
--url 'https://petstore.example.com/v1/pets/{petId}'
const response = await fetch('https://petstore.example.com/v1/pets/{petId}', {
method: 'GET'
});
const data = await response.json();
console.log(data);
import requests
response = requests.get("https://petstore.example.com/v1/pets/{petId}")
print(response.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://petstore.example.com/v1/pets/{petId}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
using System.Net.Http;
var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("GET"), "https://petstore.example.com/v1/pets/{petId}");
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
import java.net.URI;
import java.net.http.*;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://petstore.example.com/v1/pets/{petId}"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Path Parameters #
| Name | Type | Required | Description |
|---|---|---|---|
petId | integer (int64) | Required | ID of the pet |
Responses #
200 — The pet #
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Required | |
tag | string | Optional | |
id | integer (int64) | Required |
Example 200 response
Copy
{
"name": "Mochi",
"tag": "cat",
"id": 1
}
404 — Pet not found #
Response #
200
{
"name": "Mochi",
"tag": "cat",
"id": 1
}