npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wp-api-ng7

v3.0.0-beta.1

Published

WordPress WP-API v2 client for Angular2

Downloads

7

Readme

Fork of buggy1985/wp-api-angular -> wordpress-clients/wp-api-angular

================

Join the chat at https://gitter.im/shprink/wp-api-angular

Ng services to consume WP-API v2

Live Demo

If you want to use AngularJS v1, here is the latest version: v2.0.0-rc3. npm i [email protected]

Installation

npm install wp-api-angular

TypeScript

Nothing special if you use TS

UMD

UMD files are available wp-api-angular.umd.js and wp-api-angular.umd.min.js, the Live Demo uses them with systemJS

Bootstrap

An exported function WpApiLoaderFactory is mandatory to be used with AoT compilation or Ionic 2.

import { 
  WpApiModule,
  WpApiLoader,
  WpApiStaticLoader
} from 'wp-api-angular'

export function WpApiLoaderFactory() {
  return new WpApiStaticLoader('http://YOUR_DOMAIN/wp-json/', /* namespace is optional, default: '/wp/v2' */);
}

@NgModule({
  imports: [
    BrowserModule,
    WpApiModule.forRoot({
      provide: WpApiLoader,
      useFactory: (WpApiLoaderFactory)
    })
  ],
  bootstrap: [App]
})
export class AppModule { }

API

Every method return an Obervable. If you want to get a Promise you will need to add the rxjs toPromise operator:


class Test {
  constructor(private wpApiPosts: WpApiPosts) {
    this.wpApiPosts.getList()
      .toPromise()
      .then(response => response)
      .then(body => {})
      .catch(error => {})
  }
}

RequestOptionsArgs

Every request can have an optional httpOptions object.

This is where you can add query string to your request or change the headers (see below).

import { HttpHeaders } from '@angular/common/http';

const httpOptions = {
  headers: new HttpHeaders({
    'Content-Type': 'application/json;charset=UTF-8',
    'Access-Control-Allow-Origin': '*',
    'Access-Control-Max-Age': '1728000',
    'Access-Control-Allow-Headers': 'Content-Type, Content-Range, Content-Disposition, Content-Description'
    'Access-Control-Allow-Methods': 'DELETE, HEAD, GET, OPTIONS, POST, PUT'
  })
};

wpApiPosts.getList(httpOptions);

WpApiPosts

  getList(options?: object): Observable<object>;
  get(postId, options?: object): Observable<object>;
  create(body: any, options?: object): Observable<object>;
  update(postId, body: any, options?: object): Observable<object>;
  delete(postId, options?: object): Observable<object>;
  getMetaList(postId, options?: object): Observable<object>;
  getMeta(postId, metaId, options?: object): Observable<object>;
  getRevisionList(postId, options?: object): Observable<object>;
  getRevision(postId, revisionId, options?: object): Observable<object>;
  getCategoryList(postId, options?: object): Observable<object>;
  getCategory(postId, categoryId, options?: object): Observable<object>;
  getTagList(postId, options?: object): Observable<object>;
  getTag(postId, tagId, options?: object): Observable<object>;

WpApiPages

  getList(options?: object): Observable<object>;
  get(pageId: number, options?: object): Observable<object>;
  create(body: any, options?: object): Observable<object>;
  update(pageId: number, body: any, options?: object): Observable<object>;
  delete(pageId: number, options?: object): Observable<object>;
  getMetaList(pageId: number, options?: object): Observable<object>;
  getMeta(pageId: number, metaId: number, options?: object): Observable<object>;
  getRevisionList(pageId: number, options?: object): Observable<object>;
  getRevision(pageId: number, revisionId: number, options?: object): Observable<object>;

WpApiComments

  getList(options?: object): Observable<object>;
  get(commentId: number, options?: object): Observable<object>;
  create(body: any, options?: object): Observable<object>;
  update(commentId: number, body: any, options?: object): Observable<object>;
  delete(commentId: number, options?: object): Observable<object>;

WpApiTypes

  getList(options?: object): Observable<object>;
  get(postType: string, options?: object): Observable<object>;

WpApiMedia

  getList(options?: object): Observable<object>;
  get(mediaId: number, options?: object): Observable<object>;
  create(body: any, options?: object): Observable<object>;
  update(mediaId: number, body: any, options?: object): Observable<object>;
  delete(mediaId: number, options?: object): Observable<object>;

WpApiUsers

  getList(options?: object): Observable<object>;
  me(options?: object): Observable<object>;
  get(userId: number, options?: object): Observable<object>;
  create(body: any, options?: object): Observable<object>;
  update(userId: number, body: any, options?: object): Observable<object>;
  delete(userId: number, options?: object): Observable<object>;

WpApiTaxonomies

  getList(options?: object): Observable<object>;
  get(taxonomiesType: string, options?: object): Observable<object>;

WpApiStatuses

  getList(options?: object): Observable<object>;
  get(statusesName: string, options?: object): Observable<object>;

WpApiTerms

taxonomiesType can be tags, categories and more.

  getList(taxonomiesType: string, options?: object): Observable<object>;
  get(taxonomiesType: string, termId: number, options?: object): Observable<object>;
  create(taxonomiesType: string, body: any, options?: object): Observable<object>;
  update(taxonomiesType: string, termId: number, body: any, options?: object): Observable<object>;
  delete(taxonomiesType: string, termId: number, options?: object): Observable<object>;

WpApiCustom

  getList(options?: object): Observable<object>;
  get(customId: number, options?: object): Observable<object>;
  create(body: any, options?: object): Observable<object>;
  update(customId: number, body: any, options?: object): Observable<object>;
  delete(customId: number, options?: object): Observable<object>;

Authentication

TO BE DEFINED

Contribute

npm install

# Open two terminals
# and run watch to build on the lib files changes
npm run watch

# in the other terminal run following to build the test page
npm start

Open http://localhost:8080