PicsAPI Docs
Search…
⌃K

Generate an image

Before generating images, you must first have a template to apply.
You can create or clone templates directly on the web app.
These are the parameters that should go in the request.
The "transformation" object indicates to the API which transformation to perform to the template.
post
https://api.picsapi.com/v1
/render
The transformation object should contain the layers that you want to edit.
List of layers in a template.
If we want to edit the layers title and article_image
The body object looks like this:
1
{
2
"template_id": "<template-id>",
3
"transformations": {
4
"title": {
5
"color": "rgb(0,0,0)",
6
"font_size": "55",
7
"text_align": "center",
8
"font_family": "Arial",
9
"text": "Text to enter"
10
},
11
"article_image": {
12
"src": "https://link.com/image.jpg"
13
}
14
}

Code Examples

cURL

curl -X "POST" "https://api.picsapi.com/v1/render" \
-H 'Authorization: Bearer <api-token>' \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
"template_id": "<template-id>",
"transformations": {
"price": {
"color": "rgb(0,0,0)",
"font_size": "32",
"text_align": "center",
"font_family": "Arial",
"text": "Text to enter"
}
}
}'

PHP cURL

1
<?php
2
3
// get cURL resource
4
$ch = curl_init();
5
6
// set url
7
curl_setopt($ch, CURLOPT_URL, 'https://api.picsapi.com/v1/render');
8
9
// set method
10
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
11
12
// return the transfer as a string
13
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
14
15
// set headers
16
curl_setopt($ch, CURLOPT_HTTPHEADER, [
17
'Authorization: Bearer <api-token>',
18
'Content-Type: application/json; charset=utf-8',
19
]);
20
21
// json body
22
$json_array = [
23
'template_id' => '<template-id>',
24
'transformations' => [
25
'price' => [
26
'color' => 'rgb(0,0,0)',
27
'font_family' => 'Arial',
28
'font_size' => '32',
29
'text_align' => 'center',
30
'text' => 'Text to enter'
31
]
32
]
33
];
34
$body = json_encode($json_array);
35
36
// set body
37
curl_setopt($ch, CURLOPT_POST, 1);
38
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
39
40
// send the request and save response to $response
41
$response = curl_exec($ch);
42
43
// stop if fails
44
if (!$response) {
45
die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
46
}
47
48
echo 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;
49
echo 'Response Body: ' . $response . PHP_EOL;
50
51
// close curl resource to free up system resources
52
curl_close($ch);
<?php
// Include Guzzle. If using Composer:
// require 'vendor/autoload.php';
use GuzzleHttp\Pool;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
$client = new Client();
$request = new Request(
"POST",
"https://api.picsapi.com/v1/render",
[
"Authorization" => "Bearer <api-key>",
"Content-Type" => "application/json; charset=utf-8"
],
"{\"template_id\":\"<template-id>\",\"transformations\":{\"price\":{\"text\":\"Text to enter\",\"color\":\"rgb(0,0,0)\",\"font_family\":\"Arial\",\"font_size\":\"32\",\"text_align\":\"center\"}}}");
$response = $client->send($request);
echo "Response HTTP : " . $response->getStatusCode() . "
";

NodeJS (Axios)

axios({
"method": "POST",
"url": "https://api.picsapi.com/v1/render",
"headers": {
"Authorization": "Bearer <api-token>",
"Content-Type": "application/json; charset=utf-8"
},
"data": {
"template_id": "<template-id>",
"transformations": {
"price": {
"color": "rgb(0,0,0)",
"font_size": "32",
"text_align": "center",
"font_family": "Arial",
"text": "Text to enter"
}
}
}
})

NodeJS (http/s)

(function(callback) {
'use strict';
const httpTransport = require('http');
const responseEncoding = 'utf8';
const httpOptions = {
hostname: 'api.picsapi.com',
port: '443',
path: '/v1/render',
method: 'POST',
headers: {"Authorization":"Bearer <api-token>","Content-Type":"application/json; charset=utf-8"}
};
httpOptions.headers['User-Agent'] = 'node ' + process.version;
const request = httpTransport.request(httpOptions, (res) => {
let responseBufs = [];
let responseStr = '';
res.on('data', (chunk) => {
if (Buffer.isBuffer(chunk)) {
responseBufs.push(chunk);
}
else {
responseStr = responseStr + chunk;
}
}).on('end', () => {
responseStr = responseBufs.length > 0 ?
Buffer.concat(responseBufs).toString(responseEncoding) : responseStr;
callback(null, res.statusCode, res.headers, responseStr);
});
})
.setTimeout(0)
.on('error', (error) => {
callback(error);
});
request.write("{\"template_id\":\"<template-id>\",\"transformations\":{\"price\":{\"text\":\"Text to enter\",\"color\":\"rgb(0,0,0)\",\"font_family\":\"Arial\",\"font_size\":\"32\",\"text_align\":\"center\"}}}")
request.end();
})((error, statusCode, headers, body) => {
console.log('ERROR:', error);
console.log('STATUS:', statusCode);
console.log('HEADERS:', JSON.stringify(headers));
console.log('BODY:', body);
});
Last modified 1mo ago