-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use API #10
Comments
Hi, Which endpoint are you having an issue with, specifically? You can find information about how to do conversions in the README. Though, we're happy to help if you have a specific question. |
Can you give me the example code to call API by python please? |
@datnguyen20007 You can try this (example of dxf -> svg) import requests
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
}
# this being the path to the file you wish to convert
with open('myvector.dxf', 'rb') as f:
data = f.read()
# this should get you a JSON response with a download URL
response = requests.post('https://vector.express/api/v2/public/convert/dxf/cadlib/svg/', headers=headers, data=data) ...and to download your file: # Use the URL you received earlier
response = requests.get('https://vector.express/api/v2/public/files/[id].svg')
with open('converted.svg', 'wb') as f:
f.write(response.content) If you have subscribed, and need help with the metered endpoints, @corrideat should be able to help you out. |
Dear @FrankSandqvist
Secondly, save the file After I test it well, I will discuss about the price.
I want to convert SVG to PLT and .CUT to let the cutting machine to cut the paper. |
Dear @corrideat Could you help me please? import requests headers = { this being the path to the file you wish to convertwith open('myvector.dxf', 'rb') as f: this should get you a JSON response with a download URLresponse = requests.post('https://vector.express/api/v2/public/convert/dxf/cadlib/svg/', headers=headers, data=data) and I got the result: then I use code with open('converted.svg', 'wb') as f: and get an empty file SVG. Can you explain me more please? |
Hi @datnguyen20007, The issue you seem to have is that you're using import requests
headers = {
'Content-Type': 'application/octet-stream',
}
# this being the path to the file you wish to convert
with open('myvector.dxf', 'rb') as f:
data = f.read()
# this should get you a JSON response with a download URL
response = requests.post('https://vector.express/api/v2/public/convert/dxf/cadlib/svg/', headers=headers, data=data)
# Just for debugging purposes.
# For production use, you also need to check if the HTTP status code was a
# success response or not.
print(response.json())
# this is the result of the conversion, which you need to download
result = response.json()['resultUrl']
# Use the URL you received earlier
response = requests.get(result)
with open('converted.svg', 'wb') as f:
f.write(response.content) I hope that that helps. ETA: Although we don't currently have a Python SDK, you can take a look at our TypeScript SDK to get an idea of how things work if you need an example implementation. |
Dear @corrideat ,
Later, I try to convert PLT to SVG by this endpoint Then I got this error. Could you please help me with those problems ? Thank you very much |
Hi, Regarding the issue with Uniconvertor: unfortunately it's, in my experience, not very reliable, and because of this we were considering dropping support. It's still included because, when it works, it supports a range wide of files. Note that we support chaining convertors, so most of the time this is not an issue. Regarding the second problem, can you please provide an example file that triggers the issue? Thanks, |
Dear @corrideat , Could you please check those files (plt, dxf) ? and try to convert to SVG at the correct size.
Thank you very much. |
Dear Vector Express,
Could you please write more detail about the API to call with full link to API?
I want to buy but I don't know how to use your API by python language.
Thank you very much
The text was updated successfully, but these errors were encountered: