datacircle

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Datacircle tools for the GitHub Copilot SDK (Go)

Find the best GTM APIs. We benchmark all the GTM APIs and we put the results on our website: https://datacircle.dev

This Go module gives a GitHub Copilot SDK session four tools. The tools call Datacircle's open API, https://api.datacircle.dev/v1. You need no key and no account.

Tool What the tool gives Call
datacircle_list_apis Every GTM API on Datacircle, with the API's slug, number of plans, number of providers and best plan GET /apis
datacircle_best_plans One API's plans, sorted by score out of 100, best first. Each plan comes with a rank and a price per 1,000 calls GET /apis/{slug}/best
datacircle_search_plans Plans that match a provider or plan name, on all APIs or on one API. Sort by score, provider or price GET /plans
datacircle_provider The APIs a provider sells, and the provider's rank on each API GET /providers/{slug}

Install

go get github.com/waynehamadi/copilot-sdk-go-datacircle

You need Go 1.26 and the Copilot SDK for Go v2.0.0 or later, github.com/microsoft/copilot-sdk/go/v2.

Add the tools to a session

package main

import (
	"context"
	"fmt"
	"log"
	"time"

	copilot "github.com/microsoft/copilot-sdk/go/v2"
	datacircle "github.com/waynehamadi/copilot-sdk-go-datacircle"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
	defer cancel()

	client := copilot.NewClient(&copilot.ClientOptions{Mode: copilot.ModeCodingAgent})
	if err := client.Start(ctx); err != nil {
		log.Fatal(err)
	}
	defer client.Stop()

	tools := datacircle.Tools()
	// Add your own tools here too: tools = append(tools, myTool)

	session, err := client.CreateSession(ctx, &copilot.CreateSessionOptions{
		Model:       "gpt-5",
		Tools:       copilot.SessionToolOptions{Definitions: tools},
		Permissions: copilot.SessionPermissionOptions{OnRequest: copilot.PermissionHandler.ApproveAll},
	})
	if err != nil {
		log.Fatal(err)
	}
	defer session.Disconnect()

	reply, err := session.SendAndWait(ctx, copilot.MessageOptions{
		Prompt: "Which email finder API is the best, and what does it cost?",
	})
	if err != nil {
		log.Fatal(err)
	}
	if message, ok := reply.Data.(*copilot.AssistantMessageData); ok {
		fmt.Println(message.Content)
	}
}

Before you build, run the SDK's bundler from your main package's folder. The bundler embeds the SDK's runtime in your app:

go get -tool github.com/microsoft/copilot-sdk/go/v2/cmd/bundler
go tool bundler
go build

The tools work the same with the SDK's in-process runtime and with the runtime over stdio (copilot.SpawnedStdioConnection). The tools also work with your own model and key, through the SDK's custom providers.

If you set Mode: copilot.ModeEmpty in copilot.ClientOptions, a session runs only the tools listed in AvailableTools. Add the Datacircle tools to AvailableTools:

tools := copilot.SessionToolOptions{
	Definitions:    datacircle.Tools(),
	AvailableTools: copilot.NewToolSet().AddCustom("*").ToSlice(),
}

Permissions

The four tools read data and change nothing. SkipPermission is true by default, so each tool runs with no permission prompt. Set SkipPermission to false and your permission handler approves or denies each call:

tools := datacircle.Tools()
for i := range tools {
	tools[i].SkipPermission = false
}

Tool inputs and results

Tools makes each tool with the SDK's copilot.DefineTool. Each tool has an input struct, such as BestPlansInput. The module builds the tool's schema from the input struct. Leave out limit and the tool gives 10 results. Each tool returns the answer as JSON.

Each plan comes with a rank, provider, plan, score, price per 1,000 (perThousand, in dollars) and a page on datacircle.dev. That page lists every field. The tools take a slug like email-finder, an API's name or a provider's name.

The tool gives a failure result when the API gives no data. An unknown slug is one example. The result quotes the API's error message and says what input to send instead. The model reads that result and can call the tool again. The tool gives the same failure result for a network failure or a bad input.

To choose the HTTPClient the tools use, call datacircle.New(cfg).Tools() with a datacircle.Config. datacircle.New(cfg).Tools() gives the same tools as Tools. Use the config to give the client a timeout or a proxy. Leave HTTPClient as nil and the tools use http.DefaultClient.

tools := datacircle.New(&datacircle.Config{HTTPClient: &http.Client{Timeout: 30 * time.Second}}).Tools()

Call a tool yourself

You can also call each tool as a Go method, without a session:

out, err := datacircle.New(nil).BestPlans(ctx, datacircle.BestPlansInput{Slug: "email-finder", Limit: 3})
if err != nil {
	log.Fatal(err)
}
for _, plan := range out.Plans {
	fmt.Println(plan.Provider, plan.Plan, plan.Page)
}

Network

Each tool call makes one HTTPS GET request to https://api.datacircle.dev/v1 and nothing else. The request holds only the tool's own arguments: no key, no config, nothing from your sessions. The API takes up to 60 calls a minute from one IP address. The tool waits once, for a minute at most, when the API asks the tool to wait. The module depends only on the Copilot SDK and golang.org/x/text. The module stores nothing.

MIT license.

Documentation

Overview

Package datacircle gives a GitHub Copilot SDK session four tools on Datacircle's open API: find the best GTM APIs.

The API needs no key: https://api.datacircle.dev/v1 (its spec: https://api.datacircle.dev/v1/openapi.json). More at https://datacircle.dev

Index

Constants

View Source
const (
	ListAPIsName    = "datacircle_list_apis"
	BestPlansName   = "datacircle_best_plans"
	SearchPlansName = "datacircle_search_plans"
	ProviderName    = "datacircle_provider"
)
View Source
const BaseURL = "https://api.datacircle.dev/v1"

BaseURL is the API's address.

View Source
const Version = "0.1.0"

Version is this module's version, sent in each call's User-Agent.

Variables

Names are the four tools' names, in the order Tools gives them.

Functions

func Tools

func Tools() []copilot.Tool

Tools gives the four tools for a session's Tools.Definitions, beside the app's own, calling BaseURL with http.DefaultClient. A new copy at each call.

Types

type API

type API struct {
	API       string   `json:"api" jsonschema:"The API's name on the sheet"`
	Slug      string   `json:"slug" jsonschema:"Its slug, as datacircle_best_plans takes it"`
	Plans     int      `json:"plans" jsonschema:"How many plans it has"`
	Providers int      `json:"providers" jsonschema:"How many providers sell it"`
	Best      *TopPlan `json:"best,omitempty" jsonschema:"Its best plan"`
	BestPage  string   `json:"bestPage,omitempty" jsonschema:"Its page on datacircle.dev that ranks its providers"`
}

API is one API on the sheet.

type BestPlansInput

type BestPlansInput struct {
	Slug  string `json:"slug" jsonschema:"The API's slug, like email-finder or linkedin-profile, as datacircle_list_apis gives it"`
	Limit int    `json:"limit,omitempty" jsonschema:"How many plans to give, 1 to 50. 10 when left out"`
}

BestPlansInput is datacircle_best_plans' input.

type BestPlansOutput

type BestPlansOutput struct {
	API       string `json:"api"`
	Slug      string `json:"slug"`
	SheetPage string `json:"sheetPage,omitempty" jsonschema:"The API's sheet on datacircle.dev, its plans and their prices"`
	BestPage  string `json:"bestPage,omitempty" jsonschema:"The API's page on datacircle.dev that ranks its providers"`
	Total     int    `json:"total" jsonschema:"How many plans the API has"`
	Plans     []Plan `json:"plans" jsonschema:"Up to limit of its plans, best first"`
}

BestPlansOutput is datacircle_best_plans' result.

type Config

type Config struct {
	BaseURL    string
	HTTPClient *http.Client
}

Config sets where the tools call. Its zero value, or nil, calls BaseURL with http.DefaultClient.

type ListAPIsInput

type ListAPIsInput struct {
	Query string `` /* 180-byte string literal not displayed */
	Limit int    `json:"limit,omitempty" jsonschema:"How many APIs to give, 1 to 200. 10 when left out: total says how many matched"`
}

ListAPIsInput is datacircle_list_apis' input.

type ListAPIsOutput

type ListAPIsOutput struct {
	Total int    `json:"total" jsonschema:"How many APIs matched"`
	APIs  []API  `json:"apis" jsonschema:"Up to limit of them"`
	Note  string `json:"note,omitempty" jsonschema:"Where to look instead, when no API's name holds every word of the query"`
}

ListAPIsOutput is datacircle_list_apis' result.

type Plan

type Plan struct {
	API                 string   `json:"api" jsonschema:"The API, as the sheet names it"`
	Rank                *int     `json:"rank,omitempty" jsonschema:"The plan's place among its API's scored plans, 1 the best. Absent on a plan with no score"`
	Provider            string   `json:"provider" jsonschema:"Who sells it"`
	Plan                string   `json:"plan" jsonschema:"The plan's name on the provider's pricing page"`
	Score               *float64 `json:"score,omitempty" jsonschema:"Its score out of 100 on Datacircle's benchmark. Absent until its call is benchmarked"`
	PerThousand         *float64 `json:"perThousand,omitempty" jsonschema:"What 1,000 items cost on it, in dollars. Absent with no public price"`
	NotFoundPerThousand *float64 `json:"notFoundPerThousand,omitempty" jsonschema:"What 1,000 items it has no answer for cost, in dollars"`
	Billing             string   `json:"billing" jsonschema:"How you pay, like free, on-demand, one-time, contact or monthly"`
	Pay                 *float64 `json:"pay,omitempty" jsonschema:"The plan's whole price, in its currency"`
	Currency            string   `json:"currency" jsonschema:"The currency of pay, as an ISO 4217 code"`
	Page                string   `json:"page" jsonschema:"The plan's page on datacircle.dev"`
}

Plan is one plan: the keys that choose a plan. Its page on datacircle.dev gives every other.

type ProviderAPI

type ProviderAPI struct {
	API      string        `json:"api"`
	Slug     string        `json:"slug"`
	Rank     *int          `json:"rank,omitempty" jsonschema:"Its place among the API's providers, 1 the best. Absent where it has none"`
	BestPage string        `json:"bestPage,omitempty"`
	Plans    int           `json:"plans" jsonschema:"How many plans it has on the API"`
	Best     *ProviderPlan `json:"best,omitempty" jsonschema:"Its best plan on the API"`
}

ProviderAPI is one API a provider sells.

type ProviderInput

type ProviderInput struct {
	Slug  string `json:"slug" jsonschema:"The provider's slug, like bright-data, or its name, like Bright Data: the name is made a slug"`
	Limit int    `json:"limit,omitempty" jsonschema:"How many of its APIs to give, its best rank first, 1 to 200. 10 when left out"`
}

ProviderInput is datacircle_provider's input.

type ProviderOutput

type ProviderOutput struct {
	About    string        `json:"about" jsonschema:"The counts and its best rank, in words"`
	Provider string        `json:"provider"`
	Slug     string        `json:"slug"`
	Website  string        `json:"website,omitempty"`
	Total    int           `json:"total" jsonschema:"How many APIs it sells"`
	Ranked   int           `json:"ranked" jsonschema:"On how many of them it has a rank"`
	APIs     []ProviderAPI `json:"apis" jsonschema:"Up to limit of them, its best rank first"`
}

ProviderOutput is datacircle_provider's result.

type ProviderPlan

type ProviderPlan struct {
	Plan        string   `json:"plan"`
	Score       *float64 `json:"score,omitempty"`
	PerThousand *float64 `json:"perThousand,omitempty"`
	Page        string   `json:"page"`
}

ProviderPlan is a provider's best plan on one API.

type SearchPlansInput

type SearchPlansInput struct {
	API    string `` /* 162-byte string literal not displayed */
	Query  string `json:"query,omitempty" jsonschema:"Words that must all appear in the provider's or plan's name, like bright data"`
	Sort   string `json:"sort,omitempty" jsonschema:"score (best first, the default), provider (A to Z) or price ($ per 1,000, lowest first)"`
	Limit  int    `json:"limit,omitempty" jsonschema:"How many plans to give, 1 to 50. 10 when left out"`
	Offset int    `json:"offset,omitempty" jsonschema:"How many found plans to skip first. 0 when left out"`
}

SearchPlansInput is datacircle_search_plans' input.

type SearchPlansOutput

type SearchPlansOutput struct {
	Total     int    `json:"total" jsonschema:"How many plans were found"`
	Offset    int    `json:"offset" jsonschema:"How many found plans were skipped first"`
	SheetPage string `json:"sheetPage,omitempty" jsonschema:"The API's sheet on datacircle.dev, for one API's plans"`
	BestPage  string `json:"bestPage,omitempty" jsonschema:"The API's page on datacircle.dev that ranks its providers"`
	Plans     []Plan `json:"plans" jsonschema:"Up to limit of the plans found"`
	Note      string `json:"note,omitempty" jsonschema:"What was searched instead of the input, when it found nothing as it was"`
}

SearchPlansOutput is datacircle_search_plans' result.

type Toolset

type Toolset struct {
	// contains filtered or unexported fields
}

Toolset runs the four tools: datacircle_list_apis, datacircle_best_plans, datacircle_search_plans and datacircle_provider. Its methods are safe to call from many goroutines.

func New

func New(cfg *Config) *Toolset

New gives the four tools, calling where cfg says: nil calls BaseURL with http.DefaultClient.

func (*Toolset) BestPlans

func (t *Toolset) BestPlans(ctx context.Context, in BestPlansInput) (BestPlansOutput, error)

BestPlans runs datacircle_best_plans: an API's plans, best first.

func (*Toolset) ListAPIs

func (t *Toolset) ListAPIs(ctx context.Context, in ListAPIsInput) (ListAPIsOutput, error)

ListAPIs runs datacircle_list_apis: the APIs on the sheet, those whose name holds the most of the query's words first.

func (*Toolset) Provider

func (t *Toolset) Provider(ctx context.Context, in ProviderInput) (ProviderOutput, error)

Provider runs datacircle_provider: the APIs one provider sells, its best rank first, with its best plan on each.

func (*Toolset) SearchPlans

func (t *Toolset) SearchPlans(ctx context.Context, in SearchPlansInput) (SearchPlansOutput, error)

SearchPlans runs datacircle_search_plans: the plans whose provider's or plan's name holds the query, on every API or one.

func (*Toolset) Tools

func (t *Toolset) Tools() []copilot.Tool

Tools gives the four tools for a session's Tools.Definitions, beside the app's own: datacircle_list_apis (GET /apis), datacircle_best_plans (GET /apis/{slug}/best), datacircle_search_plans (GET /plans) and datacircle_provider (GET /providers/{slug}). Each is made by copilot.DefineTool from its input struct, its schema given each limit's bounds and sort's values. Each runs with no permission prompt (SkipPermission), as the four only read: set a tool's SkipPermission to false for the session's permission handler to decide. A new copy at each call.

type TopPlan

type TopPlan struct {
	Provider    string   `json:"provider"`
	Plan        string   `json:"plan"`
	Score       *float64 `json:"score,omitempty"`
	PerThousand *float64 `json:"perThousand,omitempty"`
}

TopPlan is an API's best plan.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL