|
and Register
Home
Contact Us

Patent Data Search [P010]Image Search Get Image Url

[P010]Image Search Get Image UrlPublicV1
Obtain the url accessible to the public network by uploading an image.
Note: Support JPG and PNG, File size limit is 4MB .The path is valid for 9 hour and will be emptied after expiration.

Basic Information

Resource URL: /image-search/image-upload

Request Mode: post

Return Format: application/json

The API can only be called after logging in, click to log in

API Description Document Download

Request Parameters

formData
ParameterTypeRequiredDescriptionSample
imagefiletrue
JPG,PNG
maximum 4096KB

Request Sample

  • Curl
  • NodeJs
  • Python
  • Java
curl -X POST 'https://connect.patsnap.com/image-search/image-upload?apikey='\
-H "Authorization: Bearer {token}" \
-F 'image=@C:/Users/xxxx/Pictures/demo2.jpg'
const axios = require('axios');
const fs = require('fs');
const FormData = require('form-data');

const apiUrl = "https://connect.patsnap.com/image-search/image-upload?apikey="
const filePath = 'C:\\Users\\xxxx\\Pictures\\demo2.jpg';

const form = new FormData();

form.append('image',fs.createReadStream(filePath))

const headers = {
	'Authorization': 'Bearer {token}',
	...form.getHeaders(),
};

const options = {
	method: "POST",
	url: apiUrl,
	headers: headers,
	data: form,
};

axios(options)
	.then(res => {
		console.log('Response Code:', res.status);
		console.log('Response Body:', res.data);
	})
	.catch(err => {
		console.log('Error:', err);
	});
import requests

url = "https://connect.patsnap.com/image-search/image-upload"

params = {
    "apikey": ""
}

file_path = "C:/Users/xxxx/Pictures/demo2.jpg"

headers = {
    "Authorization": "Bearer {token}"
}

files = {
  "image": open(file_path, "rb"),
}; 
  

response = requests.post(url, params=params, files=files, headers=headers, stream=True)

for line in response.iter_lines():
    if line:
        print(line.decode('utf-8'))
public static void main(String[] args) {
        /**
         * Important Tips:
         * Please Download HttpUtils From
         * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
         *
         * Please refer to the corresponding dependence:
         * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
         */

        String apiUrl = https://connect.patsnap.com/image-search/image-upload?apikey=;
        String filePath = "C:\\Users\\xxxx\\Pictures\\demo2.jpg";

        try  {
            HttpClient client = new DefaultHttpClient();

            HttpPost post = new HttpPost(apiUrl);

            post.setHeader("Authorization", "Bearer {token}");

            MultipartEntityBuilder builder = MultipartEntityBuilder.create();
            
            builder.addBinaryBody("image", new File(filePath));

            post.setEntity(builder.build());

            HttpResponse response = client.execute(post);
            String responseString = EntityUtils.toString(response.getEntity());

            System.out.println("Response Code : " + response.getStatusLine().getStatusCode());
            System.out.println("Response Body : " + responseString);
        } catch (Exception e) {
            e.printStackTrace();
        }
}
Copy

Response Parameters

CommonResponse
ParameterTypeRequiredDescriptionSample
data
objectfalse
response data
no sample
status
booleantrue
Status
false
error_msg
stringfalse
Error Message
The request parameter format is incorrect!
error_code
integertrue
Error Code
0
FileUrlResponse
ParameterTypeRequiredDescriptionSample
url
stringfalse
url
https://img1.baidu.com/it/u=3787347995,722716643&fm=26&fmt=auto
expire
integerfalse
period of validity,Unit:second
32400

Response Error Details

error_codeDescription
0Success
68300004Invalid parameter!
68300005Search api failure!
68300006Analytic basic access error!
68300007Bad request!
68300008Service error, please try again later!
68300010The file does not comply with upload specifications!
67200001API call exceeds the total limit set by the platform!
67200002Quota exceeds the limit!
67200003Access token expired or authentication error!
67200004No permission or API package quota has exceeded the limit!
67200005Insufficient balance, call failed!
67200006This client has expired and call failed!
67200007Exceeded the call limit, call failed!

Response Body

  • json
{
    "data": {
        "url": "https://img1.baidu.com/it/u=3787347995,722716643&fm=26&fmt=auto",
        "expire": 32400
    },
    "status": true,
    "error_code": 0
}
Copy
[P009]Image Search Similar Design Patent
[P009]Create Image Search Similar Design Patent V2