Backend

RESTful API

Connect Ginjou to any RESTful API using json-server conventions.

The @ginjou/with-rest-api package connects Ginjou to standard RESTful APIs. It follows the query parameter and header conventions established by json-server v0.x.x, making it compatible with many existing mocking tools and API standards.

Installation

Install the provider.

pnpm add @ginjou/with-rest-api

Setup

Initialize the fetcher and register it in your root component (App.vue or app.vue).

<script setup lang="ts">
import { defineFetchersContext } from '@ginjou/vue'
import { createFetcher } from '@ginjou/with-rest-api'

defineFetchersContext({
    default: createFetcher({
        url: 'https://api.example.com'
    })
})
</script>

<template>
    <RouterView />
</template>

Fetcher Conventions

The createFetcher implementation relies on specific query parameters and headers to handle data operations.

Pagination

The fetcher translates Ginjou's pagination state into _start and _end query parameters.

  • _start: Zero-based index of the first item.
  • _end: Zero-based index of the last item (exclusive).
The API must return the total number of records in the x-total-count HTTP header. If missing, Ginjou defaults to the length of the returned array.

Sorting

Sorting uses _sort and _order parameters.

  • _sort: Comma-separated list of fields.
  • _order: Comma-separated list of directions (asc or desc).

Filtering

Filters map to query parameters using field suffixes.

OperatorParameter SuffixExample
eq(none)title=hello
ne_neid_ne=1
gte_gteviews_gte=10
lte_lteviews_lte=20
contains_liketitle_like=ginjou
A filter with the field q sends a global search parameter (?q=keyword).
This provider does not support or / and logical operators or filtering on nested objects, as json-server does not natively support them.
Copyright © 2026