Skip to main content
Lucidite
December 7, 2023

New JSON Standard Import API

  • December 7, 2023
  • 26 replies
  • 4857 views

Hi Lucid Developers!

🌟 We just launched our JSON Import functionality within the Standard Import API, and it's set to revolutionize the way you create and visualize data in diagrams.

🔍 Why is JSON Import a Big Deal?

  • Simplicity and Power: Compared to other import methods, JSON import is less complicated yet more powerful, making it possible to auto-create detailed diagrams.
  • Fully Automated Workflow: You can now automate your entire diagram creation process more quickly. No need to open Lucid - just set up your JSON, send a request to our Import Document endpoint, and let Lucidchart handle the rest.
  • Ideal for Various Use Cases: Whether you're visualizing complex networks or leveraging AI for diagram creation, JSON import has opened up many new possibilities.

👥 Who Should Be Excited?

  • Network Professionals: Visualize intricate networks and data centers with ease.
  • AI Enthusiasts: Bring AI-generated diagrams to life quickly.
  • Automation Gurus: JSON import is the perfect option for automating workflows.

We're eager to see the innovative ways you'll use JSON import. Share examples of how you implement this new functionality or ask questions in the thread below this post

Looking forward to your creations,

Scott P, Lucid API Team 🚀

P.S. Don't forget to check out the Guides section of Lucid’s Developer Documentation for detailed guidance and tips on getting started on Lucid’s Developer Platform!

 

Pinned Reply By Jake C

For an example of how to use this new import, check out this Python project I built that imports completed Jira stories for a specified user. Before we had the Standard Import, we had to try to find this information through Jira and manually pull all the Jira tickets into a Lucid document for a user.

However, now that we have the Standard Import, this script can do all of that automatically. All you have to do is input the email of the Jira user, the year you want stories for, and which Lucid product you want to import them into. Then, the Python script will organize the stories by quarter and create a Lucid document for you.

This script has been super helpful for us going into year-end performance reviews so that we can see what work has been completed for each engineer on our team!

Comments

October 12, 2024

Hello,
I am trying to replicate the file import steps and upload the example given above in this post using Postman and the endpoint: https://api.lucid.co/documents
I did save the JSON in a document.json file, zipped it  and followed your instructions as above:

Header:


Body:

When I send the request, I get an error, it looks like the file format is not recognized; I used “x-application/vnd.lucid.standardImport” as content-type for the file.
I am working on Windows and use the build in Zip feature to generate this zipped file.

The file that I import is here:
zipped example file

could you please advice?
Thanks !
 

October 13, 2024

Hi again,
I am trying the same import (same zipped file as above) using Python in GitLab:
 

import os
import requests

api_key = 'Bearer ' + os.environ.get("API_KEY")
import_endpoint = "https://api.lucid.co/documents"

doc = 'document.lucid'
files = {"file": (doc, open(doc, mode="rb"), "x-application/vnd.lucid.standardImport")}

# Headers for the request
headers = {
    'Authorization': f'{api_key}',
    "Lucid-Api-Version": "1",
    'Content-Type': 'application/json'
}

body = {"title": "Created Document",
   "product": "lucidchart"}

response = requests.post(import_endpoint, headers=headers, data=body, files=files)

# Check the response
print('Status Code:', response.status_code)
print('Response:', response.text)


The response:
Status Code: 400
Response: {"message":"Invalid Json: Unexpected character ('-' (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid numeric value\n at [Source: (org.apache.pekko.util.ByteIterator$ByteArrayIterator$$anon$1); line: 1, column: 3]"}

Sylvia X
Lucid support team
October 15, 2024

Hi @eric_s , thanks for reaching out in this thread! Unfortunately, I’m unable to reproduce the error when I input the same values as you in your screenshot. 

However, I am able to reproduce it when the import type has been inserted in the description field (and not content type). Could you double check to make sure there is nothing inserted in your description field? You may want to uncheck and recheck the content-type field to see if that helps.

 

Our API team were able to locate the logs for that endpoint and have confirmed that we are receiving the application/octet-stream as the Content-Type from that request. We have not made any changes to that value, which indicates that this is likely an issue of Postman not sending the value correctly. 

 

In regards to your attempt at the import in Gitlab, could you try this with an Oauth 2.0 token instead an API key? I’ll also reach out to our API team to check this and will update here once we hear back. 

October 15, 2024

Hello
@Sylvia X 
Thank you!
The following Python code works as expected GitLab, both with the API Key and Oauth 2.0 :

import os
import requests

api_key = os.environ.get("API_KEY")

def uploadDoc(doc, access_token):
print("Uploading doc {0}".format(doc))
upload_url = "https://api.lucid.co/documents"
headers = {"Authorization": "Bearer {0}".format(access_token), "Lucid-Api-Version": "1"}
doc_name = doc.rsplit('.', 1)[0]
body = {"title": doc_name, "product":"lucidchart"}
files = {"file": (doc, open(doc, "rb"), "x-application/vnd.lucid.standardImport")}
return requests.post("https://api.lucid.co/documents", headers=headers, data=body, files=files)

doc = 'document.lucid'
response = uploadDoc(doc, api_key)

# Check the response
print('Status Code:', response.status_code)
print('Response:', response.text)

 

Sylvia X
Lucid support team
October 18, 2024

Hi @eric_s , thanks for following up here. It seems like this is working for you now. If this is not the case and you need further support, please let us know. 

October 18, 2024

This would be so sweet to just work with a RESTful API and just add whatever you want to add on a canvas with just a POST request, without any JS browser involvement, SDK, zip files etc and a clear and simple JSON, using the same library that is available to do all that by hand. 

Richard Udell
Lucid support team
October 18, 2024

Hi @diozsa , I agree! Lucid’s API’s helps take our visual collaboration suite to the next level. Stay tuned to the Lucid for Developers Community for updates to our developer platform!

October 18, 2024

Hi @diozsa , I agree! Lucid’s API’s helps take our visual collaboration suite to the next level. Stay tuned to the Lucid for Developers Community for updates to our developer platform!

Is there anything like that coming in the near future?

We are in the process of automating network topology diagrams dynamically and link them with the CI/CD flow in our ORG but at this current stage Lucid API is, the only thing that I can do is creating a doc and retrieving content via REST API. No editing possible.

October 19, 2024

The JSON formats required for import and what we get out with the export API are quite different (for instance  keys / values such as “type” or “class”) ; ideally both formats would be compatible in order to speed up development of new objects -  we could for example manually create diagrams and reuse (part of) the code in our imports - and eventually allow updating existing objects rather than creating new ones at each import

Michael B
Lucid product team
October 21, 2024

Hello Eric_s,

We completely agree. The two formats being different, and supporting different information, is problematic. Both in the ability to quickly spin up new projects and it limits the use cases available.

 

Unfortunately, unifying the two formats is not currently on the road-map. We do hope to provide a unified interface someday, but its not currently under development. If that were ever made available, the preexisting schemata would continue to be supported to ensure no existing applications were negatively effected.