Halaman ini belum tersedia dalam bahasa lokal Anda. Kami berusaha keras untuk menambahkan lebih banyak versi bahasa. Terima kasih atas dukungan Anda.
- What's New
- Product Bulletin
- Service Overview
- Getting Started
- User Guide
- API Reference
- SDK Reference
- FAQs
- Glossary
- More Documents
- General Reference
Show all
Copied.
Python 3 API Example
This section uses Image Tagging as an example to describe how to call Python 3 APIs.
# encoding:utf-8 import requests import base64 url = "https://{endpoint}/v2/{project_id}/image/tagging" token = "Actual token value obtained by the user" headers = {'Content-Type': 'application/json', 'X-Auth-Token': token} imagepath = r'data/image-tagging.jpg' with open(imagepath, "rb") as bin_data: image_data = bin_data.read() image_base64 = base64.b64encode(image_data).decode("utf-8") # Use Base64 encoding of images. data= {"image": image_base64} # Set either the URL or the image. response = requests.post(url, headers=headers, json=data, verify=False) print(response.text)
Parameter |
Description |
---|---|
url |
API request URL, for example, https://{endpoint}/v2/{project_id}/image/tagging. |
token |
A token is a user's access credential, which includes user identities and permissions. When you call an API to access a cloud service, a token is required for identity authentication. For details about how to obtain the token, see Authentication. |
imagePath |
Image path. An image file path or image URL is supported. The URL can be an HTTP/HTTPS or OBS URL. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot