Skip to main content
POST
/
import-libraries
Import a library bundle
curl --request POST \
  --url https://your-instance.example.com/api/import-libraries \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "libraries": [
    {
      "project": "/vercel/next.js",
      "codeSnippets": [
        {
          "id": "<string>",
          "title": "<string>",
          "description": "<string>",
          "language": "<string>",
          "codeList": [
            {
              "language": "<string>",
              "code": "<string>"
            }
          ],
          "tokens": 123
        }
      ],
      "infoSnippets": [
        {
          "id": "<string>",
          "content": "<string>",
          "breadcrumb": "<string>",
          "tokens": 123
        }
      ],
      "title": "<string>",
      "description": "<string>",
      "type": "<string>",
      "language": "English",
      "branch": "<string>",
      "docsRepoUrl": "<string>",
      "docsSiteUrl": "<string>",
      "totalTokens": 123
    }
  ],
  "force": false
}
'
import requests

url = "https://your-instance.example.com/api/import-libraries"

payload = {
"libraries": [
{
"project": "/vercel/next.js",
"codeSnippets": [
{
"id": "<string>",
"title": "<string>",
"description": "<string>",
"language": "<string>",
"codeList": [
{
"language": "<string>",
"code": "<string>"
}
],
"tokens": 123
}
],
"infoSnippets": [
{
"id": "<string>",
"content": "<string>",
"breadcrumb": "<string>",
"tokens": 123
}
],
"title": "<string>",
"description": "<string>",
"type": "<string>",
"language": "English",
"branch": "<string>",
"docsRepoUrl": "<string>",
"docsSiteUrl": "<string>",
"totalTokens": 123
}
],
"force": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
libraries: [
{
project: '/vercel/next.js',
codeSnippets: [
{
id: '<string>',
title: '<string>',
description: '<string>',
language: '<string>',
codeList: [{language: '<string>', code: '<string>'}],
tokens: 123
}
],
infoSnippets: [{id: '<string>', content: '<string>', breadcrumb: '<string>', tokens: 123}],
title: '<string>',
description: '<string>',
type: '<string>',
language: 'English',
branch: '<string>',
docsRepoUrl: '<string>',
docsSiteUrl: '<string>',
totalTokens: 123
}
],
force: false
})
};

fetch('https://your-instance.example.com/api/import-libraries', 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://your-instance.example.com/api/import-libraries",
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([
'libraries' => [
[
'project' => '/vercel/next.js',
'codeSnippets' => [
[
'id' => '<string>',
'title' => '<string>',
'description' => '<string>',
'language' => '<string>',
'codeList' => [
[
'language' => '<string>',
'code' => '<string>'
]
],
'tokens' => 123
]
],
'infoSnippets' => [
[
'id' => '<string>',
'content' => '<string>',
'breadcrumb' => '<string>',
'tokens' => 123
]
],
'title' => '<string>',
'description' => '<string>',
'type' => '<string>',
'language' => 'English',
'branch' => '<string>',
'docsRepoUrl' => '<string>',
'docsSiteUrl' => '<string>',
'totalTokens' => 123
]
],
'force' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$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://your-instance.example.com/api/import-libraries"

payload := strings.NewReader("{\n \"libraries\": [\n {\n \"project\": \"/vercel/next.js\",\n \"codeSnippets\": [\n {\n \"id\": \"<string>\",\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"language\": \"<string>\",\n \"codeList\": [\n {\n \"language\": \"<string>\",\n \"code\": \"<string>\"\n }\n ],\n \"tokens\": 123\n }\n ],\n \"infoSnippets\": [\n {\n \"id\": \"<string>\",\n \"content\": \"<string>\",\n \"breadcrumb\": \"<string>\",\n \"tokens\": 123\n }\n ],\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"type\": \"<string>\",\n \"language\": \"English\",\n \"branch\": \"<string>\",\n \"docsRepoUrl\": \"<string>\",\n \"docsSiteUrl\": \"<string>\",\n \"totalTokens\": 123\n }\n ],\n \"force\": false\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
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://your-instance.example.com/api/import-libraries")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"libraries\": [\n {\n \"project\": \"/vercel/next.js\",\n \"codeSnippets\": [\n {\n \"id\": \"<string>\",\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"language\": \"<string>\",\n \"codeList\": [\n {\n \"language\": \"<string>\",\n \"code\": \"<string>\"\n }\n ],\n \"tokens\": 123\n }\n ],\n \"infoSnippets\": [\n {\n \"id\": \"<string>\",\n \"content\": \"<string>\",\n \"breadcrumb\": \"<string>\",\n \"tokens\": 123\n }\n ],\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"type\": \"<string>\",\n \"language\": \"English\",\n \"branch\": \"<string>\",\n \"docsRepoUrl\": \"<string>\",\n \"docsSiteUrl\": \"<string>\",\n \"totalTokens\": 123\n }\n ],\n \"force\": false\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://your-instance.example.com/api/import-libraries")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"libraries\": [\n {\n \"project\": \"/vercel/next.js\",\n \"codeSnippets\": [\n {\n \"id\": \"<string>\",\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"language\": \"<string>\",\n \"codeList\": [\n {\n \"language\": \"<string>\",\n \"code\": \"<string>\"\n }\n ],\n \"tokens\": 123\n }\n ],\n \"infoSnippets\": [\n {\n \"id\": \"<string>\",\n \"content\": \"<string>\",\n \"breadcrumb\": \"<string>\",\n \"tokens\": 123\n }\n ],\n \"title\": \"<string>\",\n \"description\": \"<string>\",\n \"type\": \"<string>\",\n \"language\": \"English\",\n \"branch\": \"<string>\",\n \"docsRepoUrl\": \"<string>\",\n \"docsSiteUrl\": \"<string>\",\n \"totalTokens\": 123\n }\n ],\n \"force\": false\n}"

response = http.request(request)
puts response.read_body
{
  "message": "Queued 2 libraries for import",
  "queued": [
    "/vercel/next.js",
    "/facebook/react"
  ],
  "skipped": [
    {
      "project": "<string>",
      "reason": "already exists"
    }
  ]
}
{
"error": "repoUrl is required"
}
{
"error": "Authentication required"
}
{
"error": "Library import is available only with an offline license."
}
{
"error": "An unexpected error occurred"
}

Authorizations

Authorization
string
header
required

API key generated from Personal Settings. See Authentication.

Query Parameters

force
boolean
default:false

Overwrite libraries that already exist. Handy when posting a piped export body, which carries no force field. Without it, existing libraries are skipped.

Body

libraries
object[]
required

The libraries to import. Each carries its full snippet content; embeddings are recomputed on this install.

force
boolean
default:false

Overwrite libraries that already exist on this install

Response

Libraries accepted and queued for import

message
string
required
Example:

"Queued 2 libraries for import"

queued
string[]
required

Library identifiers queued for import

Example:
["/vercel/next.js", "/facebook/react"]
skipped
object[]
required

Libraries that were not imported, with a reason