Add a photo to a collection
curl --request POST \
--url https://api.pexafy.com/api/v1/collections/{collection_id}/photos \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"photo_id": "<string>",
"photo_thumbnail_url": "<string>",
"photo_source": "<string>",
"photo_photographer": "<string>"
}
'import requests
url = "https://api.pexafy.com/api/v1/collections/{collection_id}/photos"
payload = {
"photo_id": "<string>",
"photo_thumbnail_url": "<string>",
"photo_source": "<string>",
"photo_photographer": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
photo_id: '<string>',
photo_thumbnail_url: '<string>',
photo_source: '<string>',
photo_photographer: '<string>'
})
};
fetch('https://api.pexafy.com/api/v1/collections/{collection_id}/photos', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pexafy.com/api/v1/collections/{collection_id}/photos",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'photo_id' => '<string>',
'photo_thumbnail_url' => '<string>',
'photo_source' => '<string>',
'photo_photographer' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pexafy.com/api/v1/collections/{collection_id}/photos"
payload := strings.NewReader("{\n \"photo_id\": \"<string>\",\n \"photo_thumbnail_url\": \"<string>\",\n \"photo_source\": \"<string>\",\n \"photo_photographer\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pexafy.com/api/v1/collections/{collection_id}/photos")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"photo_id\": \"<string>\",\n \"photo_thumbnail_url\": \"<string>\",\n \"photo_source\": \"<string>\",\n \"photo_photographer\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pexafy.com/api/v1/collections/{collection_id}/photos")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"photo_id\": \"<string>\",\n \"photo_thumbnail_url\": \"<string>\",\n \"photo_source\": \"<string>\",\n \"photo_photographer\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": 123,
"photo_id": "<string>",
"photo_thumbnail_url": "<string>",
"photo_source": "<string>",
"photo_photographer": "<string>",
"added_at": "2023-11-07T05:31:56Z"
},
"meta": {
"request_id": "<string>",
"took_ms": 123
},
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Collections
Add a photo to a collection
Save a photo into a collection. The photo automatically becomes the collection’s cover if it is the first one added. Adding the same photo twice returns a 409.
POST
/
api
/
v1
/
collections
/
{collection_id}
/
photos
Add a photo to a collection
curl --request POST \
--url https://api.pexafy.com/api/v1/collections/{collection_id}/photos \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"photo_id": "<string>",
"photo_thumbnail_url": "<string>",
"photo_source": "<string>",
"photo_photographer": "<string>"
}
'import requests
url = "https://api.pexafy.com/api/v1/collections/{collection_id}/photos"
payload = {
"photo_id": "<string>",
"photo_thumbnail_url": "<string>",
"photo_source": "<string>",
"photo_photographer": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
photo_id: '<string>',
photo_thumbnail_url: '<string>',
photo_source: '<string>',
photo_photographer: '<string>'
})
};
fetch('https://api.pexafy.com/api/v1/collections/{collection_id}/photos', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pexafy.com/api/v1/collections/{collection_id}/photos",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'photo_id' => '<string>',
'photo_thumbnail_url' => '<string>',
'photo_source' => '<string>',
'photo_photographer' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pexafy.com/api/v1/collections/{collection_id}/photos"
payload := strings.NewReader("{\n \"photo_id\": \"<string>\",\n \"photo_thumbnail_url\": \"<string>\",\n \"photo_source\": \"<string>\",\n \"photo_photographer\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pexafy.com/api/v1/collections/{collection_id}/photos")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"photo_id\": \"<string>\",\n \"photo_thumbnail_url\": \"<string>\",\n \"photo_source\": \"<string>\",\n \"photo_photographer\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pexafy.com/api/v1/collections/{collection_id}/photos")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"photo_id\": \"<string>\",\n \"photo_thumbnail_url\": \"<string>\",\n \"photo_source\": \"<string>\",\n \"photo_photographer\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": 123,
"photo_id": "<string>",
"photo_thumbnail_url": "<string>",
"photo_source": "<string>",
"photo_photographer": "<string>",
"added_at": "2023-11-07T05:31:56Z"
},
"meta": {
"request_id": "<string>",
"took_ms": 123
},
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
Pass your Pexafy API key in this header.
Get your API key at pexafy.com/dashboard/api-keys/create.
Path Parameters
The numeric identifier of the collection to add the photo to.
Body
application/json
⌘I