Vectorizer.AI đưa ra API truy xuất bitmap được phát triển đầy đủ. API tự động truy xuất pixel đến các vector đầy đủ và với độ trung thực tốt nhất trong lớp.
ĐĂNG một ảnh bitmap và nhận lại kết quả vector.
$ curl https://vi.vectorizer.ai/api/v1/vectorize \ -u xyz123:[secret] \ -F image=@example.jpeg \ -o result.svg
// Requires: org.apache.httpcomponents.client5:httpclient5-fluent Request request = Request.post("https://vi.vectorizer.ai/api/v1/vectorize") .addHeader("Authorization", "Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd") .body( MultipartEntityBuilder.create() .addBinaryBody("image", new File("example.jpeg")) // TODO: Replace with your image // TODO: Add more upload parameters here .build() ); ClassicHttpResponse response = (ClassicHttpResponse) request.execute().returnResponse(); if (response.getCode() == 200) { // Write result to disk, TODO: or wherever you'd like try (FileOutputStream out = new FileOutputStream("result.svg")) { response.getEntity().writeTo(out); } } else { System.out.println("Request Failed: Status: " + response.getCode() + ", Reason: " + response.getReasonPhrase()); }
using (var client = new HttpClient()) using (var form = new MultipartFormDataContent()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "INSERT_API_KEY_HERE"); form.Add(new ByteArrayContent(File.ReadAllBytes("example.jpeg")), "image", "example.jpeg"); // TODO: Replace with your image // TODO: Add more upload parameters here var response = client.PostAsync("https://vi.vectorizer.ai/api/v1/vectorize", form).Result; if (response.IsSuccessStatusCode) { // Write result to disk, TODO: or wherever you'd like FileStream outStream = new FileStream("result.svg", FileMode.Create, FileAccess.Write, FileShare.None); response.Content.CopyToAsync(outStream).ContinueWith((copyTask) => { outStream.Close(); }); } else { Console.WriteLine("Request Failed: Status: " + response.StatusCode + ", Reason: " + response.ReasonPhrase); } }
// Requires "request" to be installed (see https://www.npmjs.com/package/request) var request = require('request'); var fs = require('fs'); request.post({ url: 'https://vi.vectorizer.ai/api/v1/vectorize', formData: { image: fs.createReadStream('example.jpeg'), // TODO: Replace with your image // TODO: Add more upload options here }, auth: {user: 'xyz123', pass: '[secret]'}, followAllRedirects: true, encoding: null }, function(error, response, body) { if (error) { console.error('Request failed:', error); } else if (!response || response.statusCode != 200) { console.error('Error:', response && response.statusCode, body.toString('utf8')); } else { // Save result fs.writeFileSync("result.svg", body); } });
$ch = curl_init('https://vi.vectorizer.ai/api/v1/vectorize'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd')); curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'image' => curl_file_create('example.jpeg'), // TODO: Add more upload options here )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200) { // Save result file_put_contents("result.svg", $data); } else { echo "Error: " . $data; } curl_close($ch);
# Either use the sample code below, or this SDK: https://pypi.org/project/vectorizer-ai/ # Requires "requests" to be installed (see https://pypi.org/project/requests/) import requests response = requests.post( 'https://vi.vectorizer.ai/api/v1/vectorize', files={'image': open('example.jpeg', 'rb')}, data={ # TODO: Add more upload options here }, auth=('xyz123', '[secret]') ) if response.status_code == requests.codes.ok: # Save result with open('result.svg', 'wb') as out: out.write(response.content) else: print("Error:", response.status_code, response.text)
# Requires: gem install httpclient require 'httpclient' client = HTTPClient.new default_header: { "Authorization" => "Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd" } response = client.post("https://vi.vectorizer.ai/api/v1/vectorize", { "image" => File.open("example.jpeg", "rb"), # TODO: Replace with your image # TODO: Add more upload parameters here }) if response.status == 200 then # Write result to disk, TODO: or wherever you'd like File.open("result.svg", 'w') { |file| file.write(response.body) } else puts "Error: Code: " + response.status.to_s + ", Reason: " + response.reason end
$ curl https://vi.vectorizer.ai/api/v1/vectorize \ -u xyz123:[secret] \ -F 'image.url=https://example.com/example.jpeg' \ -o result.svg
// Requires: org.apache.httpcomponents.client5:httpclient5-fluent Request request = Request.post("https://vi.vectorizer.ai/api/v1/vectorize") .addHeader("Authorization", "Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd") .body( MultipartEntityBuilder.create() .addTextBody("image.url", "https://example.com/example.jpeg") // TODO: Replace with your image URL // TODO: Add more upload parameters here .build() ); ClassicHttpResponse response = (ClassicHttpResponse) request.execute().returnResponse(); if (response.getCode() == 200) { // Write result to disk, TODO: or wherever you'd like try (FileOutputStream out = new FileOutputStream("result.svg")) { response.getEntity().writeTo(out); } } else { System.out.println("Request Failed: Status: " + response.getCode() + ", Reason: " + response.getReasonPhrase()); }
using (var client = new HttpClient()) using (var form = new MultipartFormDataContent()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "INSERT_API_KEY_HERE"); form.Add(new StringContent("https://example.com/example.jpeg"), "image.url"); // TODO: Replace with your image URL // TODO: Add more upload parameters here var response = client.PostAsync("https://vi.vectorizer.ai/api/v1/vectorize", form).Result; if (response.IsSuccessStatusCode) { // Write result to disk, TODO: or wherever you'd like FileStream outStream = new FileStream("result.svg", FileMode.Create, FileAccess.Write, FileShare.None); response.Content.CopyToAsync(outStream).ContinueWith((copyTask) => { outStream.Close(); }); } else { Console.WriteLine("Request Failed: Status: " + response.StatusCode + ", Reason: " + response.ReasonPhrase); } }
// Requires "request" to be installed (see https://www.npmjs.com/package/request) var request = require('request'); var fs = require('fs'); request.post({ url: 'https://vi.vectorizer.ai/api/v1/vectorize', formData: { 'image.url': 'https://example.com/example.jpeg', // TODO: Replace with your image // TODO: Add more upload options here }, auth: {user: 'xyz123', pass: '[secret]'}, followAllRedirects: true, encoding: null }, function(error, response, body) { if (error) { console.error('Request failed:', error); } else if (!response || response.statusCode != 200) { console.error('Error:', response && response.statusCode, body.toString('utf8')); } else { // Save result fs.writeFileSync("result.svg", body); } });
$ch = curl_init('https://vi.vectorizer.ai/api/v1/vectorize'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd')); curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'image.url' => 'https://example.com/example.jpeg', // TODO: Add more upload options here )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200) { // Save result file_put_contents("result.svg", $data); } else { echo "Error: " . $data; } curl_close($ch);
# Either use the sample code below, or this SDK: https://pypi.org/project/vectorizer-ai/ # Requires "requests" to be installed (see https://pypi.org/project/requests/) import requests response = requests.post( 'https://vi.vectorizer.ai/api/v1/vectorize', data={ 'image.url': 'https://example.com/example.jpeg', # TODO: Add more upload options here }, auth=('xyz123', '[secret]') ) if response.status_code == requests.codes.ok: # Save result with open('result.svg', 'wb') as out: out.write(response.content) else: print("Error:", response.status_code, response.text)
# Requires: gem install httpclient require 'httpclient' client = HTTPClient.new default_header: { "Authorization" => "Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd" } response = client.post("https://vi.vectorizer.ai/api/v1/vectorize", { "image.url" => "https://example.com/example.jpeg", # TODO: Replace with your image URL # TODO: Add more upload parameters here }) if response.status == 200 then # Write result to disk, TODO: or wherever you'd like File.open("result.svg", 'w') { |file| file.write(response.body) } else puts "Error: Code: " + response.status.to_s + ", Reason: " + response.reason end
Tích hợp và kiểm tra API miễn phí, không cần mua.
Chỉ dùng mode=test
để phát triển. Bạn có thể đánh giá chất lượng kết quả bằng cách dùng Ứng Dụng Trang Web Tương Tác Qua Lại ở trang bìa.
Kết quả sản xuất cần đăng ký mua và là 1,00credits mỗi cái.
Chúng tôi cũng để nghị kết quả xem trước mà bạn có thể cho thấy người dùng cuối của bạn trước khi họ thực hiện việc mua hàng.
Previews là các hình ảnh lớn hơn ảnh đầu vào của bạn gấp bốn lần, đến với hình mờ kín đáo, và giá 0,20credits mỗi cái.
Chỉ sử dụng mode=preview
để nhận kết quả xem lại.
Vui lòng xem trang giá cho gói đăng ký.
API sử dụng xác thực truy cập cơ bản HTTP tiêu chuẩn. Tất cả các yêu cầu đối với API phải được thực hiện qua HTTPS và bao gồm API của bạn. Các chứng nhận, có Id API là người dùng và Bí mật API là mật khẩu.
Thư viện khách hàng http của bạn phải hỗ trợ Chỉ Định Tên Máy Chủ (SNI) để thực hiện thành công các yêu cầu. Nếu bạn nhận được các lỗi giao tiếp lạ, việc thiếu hỗ trợ SNI có thể chính là lý do.
Việc sử dụng API bị giới hạn tốc độ với các hạn mức cho phép mang tính hào phóng và không có giới hạn trần vượt.
Trong quá trình hoạt động thông thường do người dùng cuối điều khiển, bạn sẽ ít gặp phải bất kỳ giới hạn tốc độ nào vì việc sử dụng có xu hướng tăng giảm theo cách mà dịch vụ xử lý một cách ổn thoả.
Dù vậy, đối với các công việc hàng loạt chúng tôi khuyến khích bắt đầu nhiều nhất là 5 chuỗi, tăng thêm 1 chuỗi mới mỗi 5 phút cho đến khi bạn đạt đến mức độ song song mong muốn. Nếu bạn cần hơn 100 chuỗi cùng lúc, vui lòng liên hệ trước khi bắt đầu.
Nếu bạn gửi quá nhiều yêu cầu thì bạn sẽ bắt đầu nhận các phản hồi 429 Too Many Requests
. Khi điều này xảy ra, bạn nên áp dụng linear back off//: trước phản hồi đầu tiên đó, đợi 5 giây cho đến khi gửi yêu cầu tiếp theo. Đối với 429 phản hồi liên tục thứ hai/, hãy đợi 2*5= 10 giây cho đến khi gửi yêu cầu tiếp theo. Đối với thứ bạ, đợi 3*5=15 giây, v.v.
Bạn có thể đặt lại bộ đếm back off sau khi yêu cầu thành công và bạn nên sử dụng back off trên cơ sở mỗi chuỗi (chẳng hạn các chuỗi nên hoạt động độc lập với nhau).
Mặc dù các yêu cầu API thường được hoàn thành trong vòng vài giây, nhưng trong quá trình tăng đột biến tải tạm thời có thể trải qua thời gian xử lý lâu hơn.
To ensure your client library doesn't prematurely terminate API requests it should be configured with an idle timeout of at least 180 seconds.
Chúng tôi sử dụng nguyên trạng HTTP quy ước để cho thấy sự thành công hay thất bại của một yêu cầu API và bao gồm những thông tin lỗi quan trọng trong Đối tượng Lỗi JSON (Error JSON Object) được trả về.
Chúng tôi luôn cố gắng trả về Đối tượng Lỗi JSON (Error JSON Object) với bất kỳ yêu nào có vấn đề. Tuy nhiên, có những thất bại của máy chủ nội bộ luôn luôn có thể về mặt lý thuyết mà việc đó dẫn đến phản hồi không không phải do lỗi JSON.
Các Thuộc Tính |
|
---|---|
status | Trạng thái phản hồi của HTTP được lập lại ở đây để giúp cho việc gỡ lỗi. |
code | Vectorizer.AI mã lỗi nội bộ. |
message | Tin nhắn lỗi người có thể đọc được, dự định có ích trong việc gỡ lỗi. |
Nếu trạng thái HTTP đối với yêu cầu của bạn là 200 thì sẽ không có Đối Tượng Lỗi JSON (Error JSON Object) nào được trả về và bạn có thể giả định một cách an toàn nói chung là yêu cầu đã thành công/.
Một số Thư Viện Khách Hàng HTTP đưa ra các lỗi/ về nguyên trạng HTTP/ trong phạm vi 400
-599
. Bạn sẽ cần nắm lấy các lỗi này và xử lý chúng phù hợp.
HTTP Status | Ý nghĩa |
---|---|
200 -299
|
Thành Công |
400 -499
|
Có vấn đề với thông tin được cung cấp trong yêu cầu (chẳng hạn đã mất một tham số). Vui lòng xem xét tin nhắn lỗi để tìm ra cách sửa nó. |
500 -599
|
Đã có Vectorizer.AI mã lỗi nội bộ. Đợi 1 chút rồi thử lại và nếu sự cố cứ tiếp tục tồn tại, vui lòng email cho chúng tôi. |
Example Error Response
{ "error" : { "status" : 400, "code" : 1006, "message" : "Failed to read the supplied image. " } }
Lỗi API gần đây được liệt kê trên trang tài khoản của bạn để tiện cho bạn gỡ lỗi.
Cũng có một danh sách tất cả các phản ứng lỗi được API trả về .
POST
https://api.vectorizer.ai/api/v1/vectorize
Để tạo vector cho một hình ảnh, bạn tải lên một tệp HTTP POST chuẩn. Hãy ghi nhớ rằng Loại-Nội Dung phải là multipart/form-data
khi tải các tệp nhị phân lên.
Bảng dưới đây bố trí tất cả các thông số API trong một mẫu làm việc thử nó ngay. Mỗi thông số có một mô tả chính, nhưng hãy chắc chắc đến kiểm tra Tài Liệu Tùy Chọn Đầu Ra chi tiết.
GET
https://api.vectorizer.ai/api/v1/account
Lấy thông tin cơ bản về tài khoản của bạn như tình trạng đăng ký và số điểm còn lại của bạn.
Các tham số |
|
---|---|
Không Có |
Các Thuộc Tính Phản Hồi |
|
---|---|
subscriptionPlan |
Gói đăng hiện mà hiện nay bạn được đăng ký cho hoặc 'không'/. |
subscriptionState |
Tình trạng đăng ký hiện nay của bạn ('hoạt động hoặc 'Quá hạn') hoặc đã kết thúc nếu không có đăng ký. |
credits |
Số điểm API còn lại trong tài khoản của bạn. 0 nếu hiện tại không có đăng ký hoặc đã đăng ký chương trình không phải API. Có thể rất nhỏ, thế nên hãy chắc chắn phân tích là Gấp Đôi. |
Hãy dùng thử
Người dùng = id API, Hộ chiếu = Bí mật API
cURL
$ curl "https://api.vectorizer.ai/api/v1/account" \ -u 123:[secret]
Example Response
{ "subscriptionPlan" : "none", "subscriptionState" : "ended", "credits" : 0 }
Ngày | Thay đổi |
---|---|
4 thg 3, 2024 | Thêm phần về thời gian chờ. |
24 thg 1, 2024 | Đã bổ sung đầu cuối Trạng Thái Tài Khoản. Đã bổ sung các lỗi API gần đây vào trang Tài Khoản. Đã bổ sung danh sách tất các các phản hồi lỗi API. |
16 thg 1, 2024 | Đã ghi nhận Lỗi Kiểu Dữ Liệu JSON. |
3 thg 10, 2023 |
Được làm rõ là output.gap_filler.enabled=true dẫn đến nhiều màu ở kết quả hơn được yêu cầu trong processing.max_colors .
|
20 thg 9, 2023 |
Đã thêm mode
|
1 thg 8, 2023 |
Đã thêm một nhóm tùy chọn kích cỡ ảnh đầu ra đầy đủ chức năng có các tùy chọn sau: output.size.scale , output.size.width , output.size.height , output.size.unit , output.size.aspect_ratio , output.size.align_x , output.size.align_y , output.size.input_dpi , và output.size.output_dpi . Đã thêm nhóm tùy chọn ảnh đầu ra bitmap với một tùy chọn: output.bitmap.anti_aliasing_mode .
|
7 thg 6, 2023 |
Đã thêm processing.max_colors
|
31 thg 5, 2023 | Đã mở rộng nhiều các thông số API. Đã cập nhật đầu cuối API. |
10 thg 3, 2023 | Phát hành lần đầu. |