Special Black Friday Deal – Up to 50% off on Annual Plans (6 months free).

3

Days

1

Hours

57

Mins

47

Secs

Junia AI API

The Junia AI API allows you to interact with the Junia platform programmatically. You can use this API to fetch published articles and integrate them into your own applications.

Note: We recommend not to use Postman to test the API integration as it is an unreliable tool.

Publish Your Articles

To make your articles available to the Junia API, you need to publish them either:

  1. Via the bulk generator to have the articles published automatically to our API once the articles are generated.
  2. Or you can publish them using the publishing option in the Junia AI Editor. Please see the screenshot below:

Publish To Junia AI API

Remember to republish your article to the Junia AI API every time you make an edit to ensure that the latest version is available through the API.

Authentication

To use the Junia AI API, you'll need to obtain an API key. You can generate an API key by navigating to the "API Key" section in your Junia dashboard settings at https://www.junia.ai/dashboard/settings.

Once you have your API key, you'll need to include it in the x-api-key header for all your API requests.

Fetching All Published Articles

To retrieve a list of all published articles, make a POST request to the following endpoint:

https://api-v1.junia.ai/api/public/collections

You can include the following optional parameters in the request body:

  • excludeSlugs (string): A comma-separated list of article slugs that you want to exclude from the response.
  • includeSlugs (string): A comma-separated list of article slugs that you want to include in the response.
  • includeContent (boolean): If set to true, the response will include the HTML content of each article. Setting this to false (the default) can improve performance by only returning the article metadata.
  • offset (number): The number of articles to skip before starting to return results. Default is 0.
  • limit (number): The maximum number of articles to return. Default is 30.

Pagination

The API uses offset-based pagination. By default, it will return 30 articles per request. You can use the offset and limit parameters to control the pagination:

  • Use offset to skip a certain number of articles (e.g., set offset: 30 to get the second page of results when using the default limit).
  • Use limit to specify how many articles you want to receive per request.

Here's an example request (general):

POST https://api-v1.junia.ai/api/public/collections

Headers

x-api-key: your-api-key

Post Body

{
"excludeSlugs": "article-to-exclude-1, article-to-exclude-2",
"includeSlugs": "article-to-include-1, article-to-include-2",
"includeContent": false,
"offset": 0,
"limit": 40
}

Example Request (Node.js)

const fetch = require('node-fetch');
const apiKey = 'your-api-key';
const requestBody = {
 excludeSlugs: 'article-to-exclude-1, article-to-exclude-2',
 includeSlugs: 'article-to-include-1, article-to-include-2',
 includeContent: false,
 "offset": 0,
 "limit": 40
};
fetch('https://api-v1.junia.ai/api/public/collections', {
 method: 'POST',
 headers: {
 'x-api-key': apiKey
 },
 body: JSON.stringify(requestBody)
})
 .then(response => response.json())
Example Request (PHP)
<?php
$apiKey = 'your-api-key';
$requestBody = [
 'excludeSlugs' => 'article-to-exclude-1, article-to-exclude-2',
 'includeSlugs' => 'article-to-include-1, article-to-include-2',
 'includeContent' => false
];

$ch = curl_init('https://api-v1.junia.ai/api/public/collections');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestBody));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
 'x-api-key: ' . $apiKey
]);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);

print_r($data);
?>

Example Response

{
 "data": [
 {
 "slug": "article-slug-1",
 "title": "Article Title 1",
 "language": "English",
 "metaTitle": "Article Meta Title 1",
 "updatedAt": "2023-08-15T12:34:56Z",
 "publishedAt": "2023-08-01T12:34:56Z",
 "createdAt": "2023-07-25T12:34:56Z",
 "featureImage": "https://example.com/article-image-1.jpg",
 "featureImageAlt": "Article 1 Feature Image",
 "metaDescription": "Article 1 meta description",
 "preview": "This is a preview of article 1",
 "content": "This is the HTML content of article 1.", 
 "markdown": "The content in marakdown format",
 "faq": 
   [{
     "question": "FAQ Question 1",
      "answer": "FAQ Answer 1"
   }]
}
],
hasMore: true
}

Fetching a Single Article

To retrieve a single published article, make a POST request to the following endpoint:

https://api-v1.junia.ai/api/public/collection

Include the following parameter in the request body:

  • slug (string): The slug of the article you want to retrieve.

Here's an example request (general):

POST https://api-v1.junia.ai/api/public/collection

Headers

x-api-key: your-api-key

Post Body

{ 
  "slug": "my-article-slug" 
}

Example Request (Node.js)

const fetch = require('node-fetch');

const apiKey = 'your-api-key';
const requestBody = {
 slug: 'my-article-slug'
};

fetch('https://api-v1.junia.ai/api/public/collection', {
 method: 'POST',
 headers: {
 'x-api-key': apiKey,
 },
 body: JSON.stringify(requestBody)
})
 .then(response => response.json())
 .then(data => console.log(data))
 .catch(error => console.error(error));

Example Request (PHP)

<?php
$apiKey = 'your-api-key';
$requestBody = [
 'slug' => 'my-article-slug'
];

$ch = curl_init('https://api-v1.junia.ai/api/public/collection');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestBody));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
 'x-api-key: ' . $apiKey
]);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);

print_r($data);
?>

Example Response

{
 "data": {
 "slug": "article-slug-1",
 "title": "Article Title 1",
 "language": "English",
 "metaTitle": "Article Meta Title 1",
 "updatedAt": "2023-08-15T12:34:56Z",
 "publishedAt": "2023-08-01T12:34:56Z",
 "createdAt": "2023-07-25T12:34:56Z",
 "featureImage": "https://example.com/article-image-1.jpg",
 "featureImageAlt": "Article 1 Feature Image",
 "metaDescription": "Article 1 meta description",
 "content": "This is the HTML content of article 1.", 
 "markdown": "The content in marakdown format",
 "faq": 
   [{
     "question": "FAQ Question 1",
     "answer": "FAQ Answer 1"
   }]
 }
}

Rate Limiting

Please note that the Junia AI API is rate-limited to prevent abuse. We recommend caching your articles as much as possible to avoid any issues.