Last active
May 14, 2024 17:18
-
-
Save homanp/99ee80c97273b103902f485f5ca572b8 to your computer and use it in GitHub Desktop.
Superagent API Request.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const apiUrl = | |
"https://api.beta.superagent.sh/api/v1/workflows/7261d731-9174-4659-9fcc-df4384058263/invoke"; | |
const outputSchema = { | |
type: "object", | |
properties: { | |
website: { type: "string" }, | |
industry: { type: "string" }, | |
number_of_employees: { type: "number" }, | |
company_type: { | |
type: "string", | |
enum: ["public", "private"], | |
}, | |
annual_revenue: { type: "number" }, | |
tagline: { type: "string" }, | |
sector: { type: "string" }, | |
location: { type: "string" }, | |
founding_year: { type: "string" }, | |
market_cap: { type: "number" }, | |
stock_ticker: { type: "string" }, | |
}, | |
required: [ | |
"website", | |
"industry", | |
"number_of_employees", | |
"company_type", | |
"annual_revenue", | |
"tagline", | |
"sector", | |
"location", | |
"founding_year", | |
"market_cap", | |
"stock_ticker", | |
], | |
}; | |
const responseData = await fetch(apiUrl, { | |
method: "POST", | |
headers: { | |
authorization: `Bearer ${process.env.SUPERAGENT_API_KEY}`, | |
"content-type": "application/json", | |
}, | |
body: JSON.stringify({ | |
input: "Company: Hubspot", | |
enableStreaming: false, | |
// Remove outputSchema to return raw text. | |
outputSchema: JSON.stringify(outputSchema), | |
}), | |
}); | |
const { data } = await responseData.json(); | |
console.log(responseData.status, data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment