API Documentation

This documents details how the PublisherKit API works. It is very simple to use.

https://api.publisherkit.com

Test API Access

GET /v1/auth

To get started you need to create a PublisherKit account. You will find your API Key in your Workspace Settings.

To authenticate, include your API Key in the 'Authorization' header of your requests.

Node.js
Copy code
1fetch('https://api.publisherkit.com/v1/auth', {
2      method: 'GET',
3      headers: {
4        'Content-Type': 'application/json',
5        'Authorization': 'Bearer ' + API_KEY,
6      }
7    });

Response

The response from the auth endpoint will be a JSON object containing the name of the workspace:

1{
2  "name": "workspace name",
3}

Create Images

POST /v1/create/images

To create an image, make a POST request to '/create/images' with an array of images in the request body. Each image should have a 'templateID' and 'modifications' field. The limit is 5 images per request.

This endpoint is synchronous and returns the images with a file link for each image instantly.

The "name" must match the name of the element in the template.

If the element is text and you want to change it, it should be added as "text":"new text".

If you want to change an image object, it should be "src":"image url".

Node.js
Copy code
1const images = [
2    {
3      "templateID": TEMPLATE_ID,
4      "modifications": [
5        {
6          "name": "headline",
7          "text": MY_HEADLINE,
8        },
9        {
10          "name": "feature_image",
11          "src": IMAGE_URL,
12        }
13      ]
14    }
15  ];
16  
17fetch('https://api.publisherkit.com/v1/create/images', {
18    method: 'POST',
19    headers: {
20      'Content-Type': 'application/json',
21      'Authorization': 'Bearer ' + API_KEY,
22    },
23    body: JSON.stringify({images})
24  });

Response

The response from the create image endpoint will be a JSON object containing the details of the created images:

1{
2  "images": [
3    {
4      "_id": "image id",
5      "file": "image file path",
6      "metadata": "image metadata"
7    }
8  ]
9}

List Templates

GET /v1/api/templates

To get all templates, make a GET request to '/api/templates'.

Node.js
Copy code
1fetch('https://api.publisherkit.com/v1/api/templates', {
2      method: 'GET',
3      headers: {
4        'Content-Type': 'application/json',
5        'Authorization': 'Bearer ' + API_KEY,
6      }
7    });

Response

The response from the templates endpoint will be an array of JSON objects, each containing the details of a template:

1[
2  {
3    "id": "template id",
4    "created": "creation timestamp",
5    "name": "template name"
6  },
7  ...
8]
If you have any questions or problems, contact us via email info@publisherkit.com