wordpress-url-api
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

wordpress-url-api

Wordpress simple sdk url like api

Examples

Create instance

import { WordpressUrlApi } from "wordpress-url-api";

export const wpApi = new WordpressUrlApi({
  host: "https://example-wp.by/",
  auth: {
    login: "login",
    password: "pass",
  },
});

add record to custom post Custom Post Type UI

const create_post = await wpApi.post("/wp/v2/orders", {
  title: "order-1",
  orders_categories: [147],
  status: "publish",
  fields: {
    certificate_id: "3",
    certificate_reservation_id: "",
    client_name: "",
    phone: "+312132",
    descr: "",
    email: "",
  },
});

put record

const update_post = await wpApi.put("/wp/v2/orders/6331", {
  title: "new title2",
  fields: {
    cert: {
      series: "10",
      barcode: "327831728731",
    },
  },
});

update ACF fields example:

const update_acf = await wpApi.post("/acf/v3/orders/6327", {
  fields: {
    certificate_id: "3",
    certificate_reservation_id: "",
    client_name: "",
    phone: "+312132",
    descr: "",
    email: "",
  },
});

TODO:

  • upload media example
  • user authorization instructions

Readme

Keywords

none

Package Sidebar

Install

npm i wordpress-url-api

Weekly Downloads

0

Version

0.0.4

License

MIT

Unpacked Size

8.54 kB

Total Files

5

Last publish

Collaborators

  • reslear