Python
import os
from meibel import MeibelClient
client = MeibelClient(api_key=os.environ["MEIBEL_API_KEY"])
stream = client.datasources.downloads.stream_progress(
datasource_id="ds_9f8a3b2c1d0e",
job_id="job_4e2a1c8b7f6d",
)
for event in stream:
if event.event == "connected":
print("Connected to progress stream")
elif event.event == "progress":
payload = event.json()
print(f"Progress: {payload}")
elif event.event == "stream_complete":
print("Download progress stream complete")
break
elif event.event == "error":
payload = event.json()
print(f"Error: {payload}")
breakimport { MeibelClient } from "meibel";
const client = new MeibelClient({ apiKey: process.env.MEIBEL_API_KEY });
const stream = await client.datasources.downloads.streamProgress({
datasourceId: "ds_8f3a2b1c",
jobId: "job_4c9d7e21",
});
for await (const event of stream) {
switch (event.event) {
case "connected":
console.log(`Connected: ${event.data}`);
break;
case "progress":
console.log(`Progress update: ${JSON.stringify(event.data)}`);
break;
case "stream_complete":
console.log("Download stream complete");
break;
case "error":
console.error(`Stream error: ${JSON.stringify(event.data)}`);
break;
}
}package main
import (
"context"
"fmt"
"os"
v2 "github.com/meibel-ai/meibel-go/v2"
)
func main() {
client := v2.NewClient(v2.WithAPIKey(os.Getenv("MEIBEL_API_KEY")))
stream, err := client.Datasources.Downloads.StreamProgress(
context.Background(),
"ds_8f3a2b1c9d0e",
"job_4d7e1f9c2a3b",
)
if err != nil {
fmt.Println("error starting stream:", err)
return
}
for event := range stream.Events() {
switch e := event.(type) {
case v2.ConnectedEvent:
fmt.Println("connected:", e.Data)
case v2.ProgressEvent:
fmt.Println("progress update received")
case v2.StreamCompleteEvent:
fmt.Println("download stream complete")
case v2.ErrorEvent:
fmt.Println("stream reported an error")
}
}
if err := <-stream.Errors(); err != nil {
fmt.Println("stream error:", err)
}
}curl --request GET \
--url https://api.meibel.ai/v2/datasources/{datasource_id}/downloads/{job_id}/progress \
--header 'Meibel-API-Key: <api-key>'const options = {method: 'GET', headers: {'Meibel-API-Key': '<api-key>'}};
fetch('https://api.meibel.ai/v2/datasources/{datasource_id}/downloads/{job_id}/progress', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.meibel.ai/v2/datasources/{datasource_id}/downloads/{job_id}/progress",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Meibel-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.meibel.ai/v2/datasources/{datasource_id}/downloads/{job_id}/progress")
.header("Meibel-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.meibel.ai/v2/datasources/{datasource_id}/downloads/{job_id}/progress")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Meibel-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Downloads
Stream Download Progress
GET
/
datasources
/
{datasource_id}
/
downloads
/
{job_id}
/
progress
Python
import os
from meibel import MeibelClient
client = MeibelClient(api_key=os.environ["MEIBEL_API_KEY"])
stream = client.datasources.downloads.stream_progress(
datasource_id="ds_9f8a3b2c1d0e",
job_id="job_4e2a1c8b7f6d",
)
for event in stream:
if event.event == "connected":
print("Connected to progress stream")
elif event.event == "progress":
payload = event.json()
print(f"Progress: {payload}")
elif event.event == "stream_complete":
print("Download progress stream complete")
break
elif event.event == "error":
payload = event.json()
print(f"Error: {payload}")
breakimport { MeibelClient } from "meibel";
const client = new MeibelClient({ apiKey: process.env.MEIBEL_API_KEY });
const stream = await client.datasources.downloads.streamProgress({
datasourceId: "ds_8f3a2b1c",
jobId: "job_4c9d7e21",
});
for await (const event of stream) {
switch (event.event) {
case "connected":
console.log(`Connected: ${event.data}`);
break;
case "progress":
console.log(`Progress update: ${JSON.stringify(event.data)}`);
break;
case "stream_complete":
console.log("Download stream complete");
break;
case "error":
console.error(`Stream error: ${JSON.stringify(event.data)}`);
break;
}
}package main
import (
"context"
"fmt"
"os"
v2 "github.com/meibel-ai/meibel-go/v2"
)
func main() {
client := v2.NewClient(v2.WithAPIKey(os.Getenv("MEIBEL_API_KEY")))
stream, err := client.Datasources.Downloads.StreamProgress(
context.Background(),
"ds_8f3a2b1c9d0e",
"job_4d7e1f9c2a3b",
)
if err != nil {
fmt.Println("error starting stream:", err)
return
}
for event := range stream.Events() {
switch e := event.(type) {
case v2.ConnectedEvent:
fmt.Println("connected:", e.Data)
case v2.ProgressEvent:
fmt.Println("progress update received")
case v2.StreamCompleteEvent:
fmt.Println("download stream complete")
case v2.ErrorEvent:
fmt.Println("stream reported an error")
}
}
if err := <-stream.Errors(); err != nil {
fmt.Println("stream error:", err)
}
}curl --request GET \
--url https://api.meibel.ai/v2/datasources/{datasource_id}/downloads/{job_id}/progress \
--header 'Meibel-API-Key: <api-key>'const options = {method: 'GET', headers: {'Meibel-API-Key': '<api-key>'}};
fetch('https://api.meibel.ai/v2/datasources/{datasource_id}/downloads/{job_id}/progress', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.meibel.ai/v2/datasources/{datasource_id}/downloads/{job_id}/progress",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Meibel-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.meibel.ai/v2/datasources/{datasource_id}/downloads/{job_id}/progress")
.header("Meibel-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.meibel.ai/v2/datasources/{datasource_id}/downloads/{job_id}/progress")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Meibel-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Was this page helpful?
⌘I