PHP module for communicating with an API built with Reflect over HTTP
Find a file
2023-11-09 11:56:18 +01:00
src fix: no request body on GET requests (#5) 2023-11-09 11:56:18 +01:00
.gitignore initial commit 2023-09-20 14:05:42 +02:00
.npmignore fix: ESM exports (#2) 2023-11-09 10:51:01 +01:00
package-lock.json initial commit 2023-09-20 14:05:42 +02:00
package.json fix: no request body on GET requests (#5) 2023-11-09 11:56:18 +01:00
README.md feat(doc): add README 2023-09-26 16:15:40 +02:00
tsconfig.json fix: ESM exports (#2) 2023-11-09 10:51:01 +01:00

Reflect API client for JavaScript

Make requests to an API built using the Reflect API framework over HTTP with JavaScript.


import { Client, Method } from "./reflect-client/Reflect.js

const api = new Client("<api_url>", "<optional_api_key");
// Make an API request with Client.call() which returns a normal JavaScript Response object
api.call("my/endpoint", Method.GET); // obj<Respone>

Supported browsers/environments:

Chrome-icon
Chrome
Firefox_logo,_2019 svg
Firefox
Safari_browser_logo svg
Safari
image
NodeJS
deno
Deno
80+ 75+ 14.1+ 20.7.0+ 1.37.0+

How to use

  1. Install with npm

    npm i reflect-client
    
  2. Initialize the class

    import { Client, Method } from "./reflect-client/Reflect.js
    
    const api = new Client("<api_url>", "<optional_api_key");
    
  3. Make API request

    Use the call() method to perform a request

    api.call("my/endpoint", Method.GET);
    
    Argument index Type Required Description
    0 string Yes Fully qualified pathname and query params of the endpoint to call
    1 Method|string Yes A supported Reflect HTTP method (eg. Method.GET) or a string represnetation of a supported method (eg. "GET")
    2 array No An optional indexed, associative, or multidimensional array that will be sent as the request body as Content-Type: application/json

    The call() function will return a Response object

Development

NodeJS required version: 20.7.0+

TypeScript required version: 5.2.2+