Update app/tools/odds.ts
Browse files- app/tools/odds.ts +4 -3
app/tools/odds.ts
CHANGED
|
@@ -6,7 +6,7 @@ function createOddsApi({ apiKey }: { apiKey: string }) {
|
|
| 6 |
input: z.string(),
|
| 7 |
});
|
| 8 |
const name = 'sports_odds';
|
| 9 |
-
const description = 'A realtime Sports Odds API. Useful for when you need to answer questions about sports odds, currently NBA and NFL. Input should be a string including a sport (nba or nfl), optionally including type (h2h, spread or o/u). Outputs a JSON array of results.';
|
| 10 |
|
| 11 |
const execute = async ({ input }: z.infer<typeof paramsSchema>) => {
|
| 12 |
try {
|
|
@@ -32,8 +32,9 @@ function createOddsApi({ apiKey }: { apiKey: string }) {
|
|
| 32 |
} else {
|
| 33 |
markets = 'spreads';
|
| 34 |
}
|
| 35 |
-
const
|
| 36 |
-
console.log(
|
|
|
|
| 37 |
const oddsResponse = await activeSports.json();
|
| 38 |
console.log(oddsResponse);
|
| 39 |
return JSON.stringify(oddsResponse);
|
|
|
|
| 6 |
input: z.string(),
|
| 7 |
});
|
| 8 |
const name = 'sports_odds';
|
| 9 |
+
const description = 'A realtime Sports Odds API. Useful for when you need to answer questions about sports odds, currently NBA and NFL. Input should be a string including a sport (nba or nfl), optionally including type (h2h, spread or o/u). Outputs a JSON array of results. Use all of the results to create an average of odds';
|
| 10 |
|
| 11 |
const execute = async ({ input }: z.infer<typeof paramsSchema>) => {
|
| 12 |
try {
|
|
|
|
| 32 |
} else {
|
| 33 |
markets = 'spreads';
|
| 34 |
}
|
| 35 |
+
const oddsUrl = `https://api.the-odds-api.com/v4/sports/${sportKey}/odds?apiKey=${apiKey}&oddsFormat=${oddsFormat}&dateFormat=${dateFormat}&markets=${markets}®ions=${regions}`;
|
| 36 |
+
console.log(oddsUrl);
|
| 37 |
+
const activeSports = await fetch(oddsUrl);
|
| 38 |
const oddsResponse = await activeSports.json();
|
| 39 |
console.log(oddsResponse);
|
| 40 |
return JSON.stringify(oddsResponse);
|