> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# JSONPlaceholder REST API

> Client-mode REST API connector for the public JSONPlaceholder fake API (posts, users, todos)

Technical Preview

## Overview

[JSONPlaceholder](https://jsonplaceholder.typicode.com/) is a free fake REST API. Use it to exercise Coreflux `TYPE REST_API` client connectors against posts, comments, users, and todos with no API key.

> [!TIP]
>
> `GET /posts/1` and `GET /users/1` return HTTP 200. `POST /posts` returns HTTP 201 with a fake id. Nothing is stored.

## Basic Syntax

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
# Coreflux REST_API template — JSONPlaceholder
# Generated from OpenAPI; credentials are placeholders only.
# Docs: https://docs.coreflux.org/latest/lot-language/routes/rest-api-routes

DEFINE ROUTE JsonplaceholderRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://jsonplaceholder.typicode.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '30'
        WITH DEFAULT_CONTENT_TYPE "application/json"
        # Optional: WITH USERNAME "YOUR_USER" / WITH PASSWORD GET SECRET "APP_PASSWORD"
    ADD EVENT Listposts
        WITH SOURCE_TOPIC "integrations/jsonplaceholder/request/Listposts"
        WITH DESTINATION_TOPIC "integrations/jsonplaceholder/response/Listposts"
        WITH METHOD "GET"
        WITH ENDPOINT "/posts"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Createpost
        WITH SOURCE_TOPIC "integrations/jsonplaceholder/request/Createpost"
        WITH DESTINATION_TOPIC "integrations/jsonplaceholder/response/Createpost"
        WITH METHOD "POST"
        WITH ENDPOINT "/posts"
        WITH HEADERS
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
        WITH BODY "{payload}"
    ADD EVENT Getpost
        WITH SOURCE_TOPIC "integrations/jsonplaceholder/request/Getpost"
        WITH DESTINATION_TOPIC "integrations/jsonplaceholder/response/Getpost"
        WITH METHOD "GET"
        WITH ENDPOINT "/posts/{value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Getpostcomments
        WITH SOURCE_TOPIC "integrations/jsonplaceholder/request/Getpostcomments"
        WITH DESTINATION_TOPIC "integrations/jsonplaceholder/response/Getpostcomments"
        WITH METHOD "GET"
        WITH ENDPOINT "/posts/{value.json.id}/comments"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Listusers
        WITH SOURCE_TOPIC "integrations/jsonplaceholder/request/Listusers"
        WITH DESTINATION_TOPIC "integrations/jsonplaceholder/response/Listusers"
        WITH METHOD "GET"
        WITH ENDPOINT "/users"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Getuser
        WITH SOURCE_TOPIC "integrations/jsonplaceholder/request/Getuser"
        WITH DESTINATION_TOPIC "integrations/jsonplaceholder/response/Getuser"
        WITH METHOD "GET"
        WITH ENDPOINT "/users/{value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Listtodos
        WITH SOURCE_TOPIC "integrations/jsonplaceholder/request/Listtodos"
        WITH DESTINATION_TOPIC "integrations/jsonplaceholder/response/Listtodos"
        WITH METHOD "GET"
        WITH ENDPOINT "/todos"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Listcomments
        WITH SOURCE_TOPIC "integrations/jsonplaceholder/request/Listcomments"
        WITH DESTINATION_TOPIC "integrations/jsonplaceholder/response/Listcomments"
        WITH METHOD "GET"
        WITH ENDPOINT "/comments"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
```

## Events

| Event | Method | Endpoint | Request topic | Response topic |
| - | - | - | - | - |
| Listposts | GET | `/posts` | `integrations/jsonplaceholder/request/Listposts` | `integrations/jsonplaceholder/response/Listposts` |
| Createpost | POST | `/posts` | `integrations/jsonplaceholder/request/Createpost` | `integrations/jsonplaceholder/response/Createpost` |
| Getpost | GET | `/posts/{value.json.id}` | `integrations/jsonplaceholder/request/Getpost` | `integrations/jsonplaceholder/response/Getpost` |
| Getpostcomments | GET | `/posts/{value.json.id}/comments` | `integrations/jsonplaceholder/request/Getpostcomments` | `integrations/jsonplaceholder/response/Getpostcomments` |
| Listusers | GET | `/users` | `integrations/jsonplaceholder/request/Listusers` | `integrations/jsonplaceholder/response/Listusers` |
| Getuser | GET | `/users/{value.json.id}` | `integrations/jsonplaceholder/request/Getuser` | `integrations/jsonplaceholder/response/Getuser` |
| Listtodos | GET | `/todos` | `integrations/jsonplaceholder/request/Listtodos` | `integrations/jsonplaceholder/response/Listtodos` |
| Listcomments | GET | `/comments` | `integrations/jsonplaceholder/request/Listcomments` | `integrations/jsonplaceholder/response/Listcomments` |

## Auth

No credentials. The template still includes `Authorization: Bearer {value.json.api_token}`. Omit the token for demos. If you retarget `BASE_ADDRESS` to a private clone, load the secret with `GET SECRET` upstream. Never commit tokens.

## Try it

1. Add the connector on a lab broker.
2. Publish `{"id": 1}` to `integrations/jsonplaceholder/request/Getpost`.
3. Subscribe to `integrations/jsonplaceholder/response/Getpost`.
4. Create: publish a JSON body such as `{"title":"coreflux","body":"demo","userId":1}` to `integrations/jsonplaceholder/request/Createpost` (the connector forwards `{payload}`).
5. Users: publish `{"id": 1}` to `integrations/jsonplaceholder/request/Getuser`.

> [!NOTE]
>
> Checked against the public API: `GET /posts/1` and `GET /users/1` returned HTTP 200; `POST /posts` returned HTTP 201. Broker MQTT round-trip was not run. `lot_lint` reported no findings on `JsonplaceholderRestApi`.

## Related

* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)
* [REST API Apps](/latest/lot-language/routes/rest-api-apps)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.