Connects a Payload app to Datacircle's open API, which ranks GTM APIs and their provider pricing plans. It adds REST endpoints, a text field for picking a GTM API, and a server-side client. It needs Payload 3 and no API key or account, and responses are cached for five minutes by default.
Payload endpoints and a field on Datacircle's open API: find the best GTM APIs. List every API and see which provider ranks first on each one. Search every provider's pricing plans. See where a provider ranks. No API key needed.
Installation
npm i @datacircle/payload-plugin0
Stars
0
Forks
0
Open Issues
4 days ago
Last Updated
212
Weekly Downloads
v0.1.0
npm Version
26.9 KB
Unpacked Size
0
Dependencies
Trends appear once the first and last snapshots are 7 days apart. Collecting since Nov 29 — 7 daily snapshots so far.
Trends appear after 7 days of data. Collecting since Dec 2 — 4 daily snapshots so far.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1478887919-root)<a href="https://payloaddirectory.dev/plugins/1478887919-root"><img src="https://payloaddirectory.dev/badge/1478887919-root.svg" alt="Payload Directory"></a>README
Find the best GTM APIs. We benchmark all the GTM APIs and we put the results on our website. See the results on datacircle.dev.
This Payload plugin gives your Payload app our benchmark results. The plugin adds endpoints to your REST API, and a field to pick a GTM API in any collection. Your own code can call our API through the plugin too. The plugin loads our open API at https://api.datacircle.dev/v1. You need no key and no account.
| Endpoint | In your code | Call |
|---|---|---|
GET /api/datacircle/apis/:slug/best | datacircleApi.best(slug, { limit, fields }) | GET /apis/{slug}/best |
GET /api/datacircle/plans | datacircleApi.plans({ api, query, sort, limit, offset, fields }) | GET /plans |
GET /api/datacircle/providers/:slug | datacircleApi.provider(slug, { fields }) | GET /providers/{slug} |
GET /api/datacircle/apis | datacircleApi.apis() | GET /apis |
You need Payload 3.
npm install @datacircle/payload-plugin
Add the plugin to your config:
// src/payload.config.ts
import { datacircle } from '@datacircle/payload-plugin'
export default buildConfig({
// ...
plugins: [datacircle()],
})
Call an endpoint:
curl "http://localhost:3000/api/datacircle/apis/email-finder/best?limit=5&fields=provider,plan,score,page"
Each endpoint gives the same JSON as our API. The spec lists every field.
email-finder. Add limit, from 1 to 50 plans. The default is 10.api (a slug), query (words from the provider name or the plan name), sort (score, provider or price), limit (1 to 50) and offset.hunter.slug from this list.A plan has about 80 fields. Pick the fields to show with fields, like fields=provider,plan,score,perThousand,page. Add fields to a providers call too. A provider's answer holds the provider's plans on each API.
Anyone can call the endpoints. To let only signed-in users call them, set access:
plugins: [datacircle({ access: (req) => Boolean(req.user) })],
To add no endpoints, set endpoints: false. The field still works.
gtmApiField() holds the slug of a GTM API, like email-finder. In the admin panel, you pick the API from a list of every API on Datacircle. Add the field to any collection or global:
// src/collections/Pages.ts
import type { CollectionConfig } from 'payload'
import { gtmApiField } from '@datacircle/payload-plugin'
export const Pages: CollectionConfig = {
slug: 'pages',
fields: [{ name: 'title', type: 'text', required: true }, gtmApiField({ required: true })],
}
The field's name is gtmApi. To change it, pass any option of a text field, like gtmApiField({ name: 'api', label: 'API' }). Payload checks that each value is the slug of an API on Datacircle. The field saves the slug as text, so a new API on Datacircle needs no migration.
After you add the field, run npx payload generate:importmap and npx payload generate:types.
datacircleApi calls our API from your server code. This page shows the 3 best plans for a page's API:
// src/app/(frontend)/pages/[id]/page.tsx
import config from '@payload-config'
import { datacircleApi } from '@datacircle/payload-plugin'
import { getPayload } from 'payload'
export default async function Page({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params
const payload = await getPayload({ config })
const page = await payload.findByID({ collection: 'pages', id })
const best = await datacircleApi.best(page.gtmApi, {
limit: 3,
fields: ['provider', 'plan', 'score', 'page'],
})
return (
<main>
<h1>{page.title}</h1>
<ol>
{best.plans.map((plan) => (
<li key={plan.page}>
<a href={plan.page}>
{plan.provider} {plan.plan}
</a>
{plan.score !== null && `: ${plan.score} out of 100`}
</li>
))}
</ol>
<p>
Ranks from <a href={best.bestPage ?? best.sheetPage}>Datacircle</a>
</p>
</main>
)
}
The plugin keeps each answer 5 minutes. The plugin calls the Datacircle API at most once every 5 minutes for each answer. A page with many visitors still makes no extra calls. The endpoints, the field and datacircleApi share what the plugin keeps. To keep each answer longer or shorter, set keepSeconds:
plugins: [datacircle({ keepSeconds: 600 })],
The API can refuse a call. The endpoint then gives a 400 or a 404 with the API's error message, like sort must be one of: score, provider, price. The endpoint gives a 502 if the API doesn't answer. It gives a 403 when access says no.
The API takes 60 calls a minute from one address. The endpoint gives a 503 if your app calls more than 60 times a minute.
In your code, datacircleApi throws a DatacircleError. The error's status holds the API's status code, or 0 if the API didn't answer.
The data is under CC BY 4.0. Each API answer holds links to our pages on datacircle.dev, like sheetPage and each plan's page. Next to each plan's data, show that plan's page link. Next to a whole list, show sheetPage.
The code is under the MIT License.
Topics
payload plugin unirate
Server-side proxy for the UniRate currency exchange and VAT API with a prefilled currency select field
514/wk0v3
payload dub
Create and manage Dub shortlinks, tags and analytics for published Payload documents
80746/wk4v4
payload operations
Typed custom RPC operations for Payload with shared Zod contracts, server endpoints and type-safe clients
77208/wk3v3
bitrix24
Send Payload form builder submissions to Bitrix24 CRM as leads or deals
76479/wk0v4
payload plugin deskcrew
Turn new documents in chosen collections into DeskCrew support tickets
696/wk0v2
payload plugin playlists
Curated YouTube creator lists with per-channel rules, review queues, quota caps and click-to-play embeds
671.8k/wk0v3