Skip to content
Business Agile
← Work
Open source · API pagination, SQL and graph · Oct 2026

fastapi-object-pagination

One page shape for an API that reads both a SQL database and a graph.

Key figures

supported Python versions3.11+
data sources, one page shape2
licence, public package on PyPIMIT

An API paginated with this library returns a `Page[Model]` object: the items, the counts, and the URLs of the previous and next pages. The same `Page` comes back whether the data was read through SQLModel or through Neontology, which talks to Neo4j and Memgraph. The clients of the API, and its OpenAPI schema, therefore do not change when the storage does.

The project in detail

It came out of a precise need, on a production application that reads part of its data from PostgreSQL and part of it from a knowledge graph, and exposes both through the same REST API. Existing pagination libraries cover SQLAlchemy well and graph stores not at all: each data source had ended up with its own page format, and the front end had to special-case them. Pulling the page object out into a library forced a single contract on both sides.

This is why I publish code like this rather than keeping it. A local patch inside one project helps nobody and nobody reviews it; a public package has a version, tests, a licence and a stable surface, and the code running for a client no longer depends on a fix only that client knows about.

Its tests cover the two read paths separately, SQLModel pagination on one side, the graph and the building of Cypher clauses on the other, and check the behaviour when an optional dependency is absent. That last point matters: the library must not require Neo4j of a project that only uses PostgreSQL, nor the other way round.

First published on PyPI on 28 October 2026, under the MIT licence; it supports Python 3.11 and above. Its documentation has its own site, built and published with the code it describes.

What was done

  1. 01

    Published on PyPI under the MIT licence, documented on its own site

  2. 02

    The same page shape for SQLModel and for a Neo4j or Memgraph graph

  3. 03

    The OpenAPI schema does not change when the storage does

  4. 04

    Tested without its optional dependencies too

  5. 05

    Extracted from a production application, not written as a demonstration

Frequently asked questions

Why publish a library instead of keeping the code in the project?

Because a public package has a version, tests, a licence and a stable surface. The code running for a client no longer depends on a local patch nobody else reviews, and the same need in another project is met by a dependency instead of a copy and paste.

How do you paginate an API that reads both a SQL database and a graph?

By pulling the page object out of the data access code. The API returns the same structure in both cases, items, counts and the URLs of the neighbouring pages, and its clients do not know where the data came from.

Does the library force you to install Neo4j?

No. The graph dependencies are optional and three tests check the behaviour when they are absent: a project that only uses PostgreSQL installs nothing extra.

Other work

FabArto
fabarto.eu
Web
Ti Kosmeo
tikosmeo.fr
Web
Antiquité Mallarmé
antiquitemallarme.fr
Web
Maison Ozaé
maisonozae.eu
Web
ScienceProtect
scienceprotect.com
AI
Neontology
github.com/ontolocy/neontology
Open source
Pousses & Plantes
Plant marketplace
App
Arbre Agile
Artificial intelligence consulting and development
Web
Groupe BERREBI
Holding company and corporate website
Web
SNCF
Rail transport, internal applications
API
Pitchichi
guide.pitchichi.com
App
Appétit
Independent bookshop, cookbooks and photography
Web
Good Day
Media, consumer mobile application
App
Fondation Nestlé France
Corporate foundation, food and health
Web
DMD Prices
Art, canvas printing, online quoting
Web
IoTBox
Connected devices, industrial solutions
Web
PrevenFit
Services for fitness clubs, subscriber area
App
Securicate
Security equipment, online shop
E-commerce
WeChamp
Sport, corporate events
Web
Jaco
Media monitoring, subscription software
App
AWA
Education and film, project with an international reach
Web
Quizz Paris
Risk prevention, public awareness
App
La Gestion en Ligne
Rental management, online service
Web
Quotidien Libre
Online press, daily news
Web
Ophtalmologie Percy
Healthcare, military hospital
Web
Flashing Records
Music, label and event programming
Web
Apérothérapie
Wine and fine food, online retail
E-commerce
Arnaud CANIZARES
Contemporary art, artist portfolio
Web
Montebello Psychologue
Psychology and neuropsychology practice
Web
TapToSupport
Donation collection for non-profits
API
24hprojects
MVP delivery platform
App
Eco-Actives
Ecological transition and DIY workshops
E-commerce

A project? Let's talk this week.

A short brief, an answer within 48 hours, a firm estimate after scoping.

Describe my project