Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (12.7k points)

I'm working with an API for tag acknowledgment ; and I get this twist order : 

How to carry out such call with curl in PYTHON?

curl "https://api.havenondemand.com/1/api/async/recognizelicenseplates/v1?url=https%3A%2F%2Fwww.havenondemand.com%2Fsample-content%2Fvideos%2Fgb-plates.mp4&source_location=GB&apikey=695e513c-xxxx-xxxx-xxxx-xxxxxxxxxx"

curl -X POST --form "url=https://www.havenondemand.com/sample-content/videos/gb-plates.mp4" --form "source_location=GB" --form "apikey=695e513c-xxxx-xxxx-a666-xxxxxxxxxx" https://api.havenondemand.com/1/api/async/recognizelicenseplates/v1

1 Answer

0 votes
by (26.4k points)

First try to install the requests module

pip install requests

Then try the below code:

import requests

API_URL = "https://api.havenondemand.com/1/api/async/recognizelicenseplates/v1"

data = {

    "url": "https://www.havenondemand.com/sample-content/videos/gb-plates.mp4",

    "source_location": "GB",

    "apikey": "695e513c-xxxx-xxxx-a666-xxxxxxxxxx"

 }

response = requests.post(API_URL, data)

print(response.json())

Essentially, any structure fields should go inside the information dictionary as key worth sets. We use requests.post() work here. The capacity/function accepts the objective URL as the primary boundary. Also, the structure esteems as the subsequent boundary.

We get a reaction object back. You can see the crude reaction by printing out the worth of response.content. In any case, in the event that you realize that the reaction is JSON, you can utilize the json() technique to parse the reaction and get back Python information type (dictionary).

Want to learn python to get expertise in the concepts of python? Join python certification course and get certified

Browse Categories

...