waynehamadi

payload plugin datacircle

by waynehamadi
Third-party services
v3
^3.0.0
MIT

Overview

Summary generated from the README

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.

Features

  • REST endpoints for best plans per API, plan search, provider rankings and the full API list
  • gtmApiField selector populated with every API on Datacircle and validated by slug
  • datacircleApi client for calling the data from server code with field selection
  • Optional access function to limit who can call the endpoints, or disable endpoints entirely
  • Shared response cache with configurable duration
  • Clear error statuses for bad requests, refusals and rate limits

Use cases

  • Show the top-ranked providers for a GTM API on a page driven by a Payload collection
  • Build a pricing comparison page by searching provider plans by name, API or price
  • Tag content with a GTM API and render ranking data alongside it

From the author

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-plugin

0

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

GitHub stars

Trends appear once the first and last snapshots are 7 days apart. Collecting since Nov 29 — 7 daily snapshots so far.

npm weekly downloads

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

77/100Excellent

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1478887919-root.svg)](https://payloaddirectory.dev/plugins/1478887919-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1478887919-root"><img src="https://payloaddirectory.dev/badge/1478887919-root.svg" alt="Payload Directory"></a>
Updated Dec 1, 2026Created Dec 1, 2026Published Dec 1, 2026

README

Datacircle for Payload

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.

EndpointIn your codeCall
GET /api/datacircle/apis/:slug/bestdatacircleApi.best(slug, { limit, fields })GET /apis/{slug}/best
GET /api/datacircle/plansdatacircleApi.plans({ api, query, sort, limit, offset, fields })GET /plans
GET /api/datacircle/providers/:slugdatacircleApi.provider(slug, { fields })GET /providers/{slug}
GET /api/datacircle/apisdatacircleApi.apis()GET /apis

Install

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()],
})

Endpoints

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.

  • best gives one API's plans, best first, by our score out of 100. An API slug looks like email-finder. Add limit, from 1 to 50 plans. The default is 10.
  • plans searches the plans. Add api (a slug), query (words from the provider name or the plan name), sort (score, provider or price), limit (1 to 50) and offset.
  • providers gives one provider's rank and plans on each API. A provider slug looks like hunter.
  • apis gives every API on our sheet, with the best plan for each. The best and plans endpoints take an API 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.

The field

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.

In your code

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>
  )
}

Fresh data

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 })],

Errors

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.

Similar plugins