Tuesday, December 22, 2015

WP-API: Endpoint Namespaces

WordPress is getting a JSON Rest API added to core. The first part of the API is actually already included. The endpoint infrastructure is in 4.4. As developers build extensions to the API, we need to take responsibility for our actions and how they can affect a site. WordPress is unique in that it is the ultimate generic API tool and anything can be created utilizing this new tool. “The infrastructure of the API itself, supports basically anything you can throw at it. If you take away the core endpoints, it is essentially a framework for building APIs, and you can build those however you like.” – Ryan McCue Namespaces To avoid collisions, namespaces are something to be thoughtful about. Namespaces are the slugs in the URL before the endpoint. Also, the schema and structure of your data should be a consideration. The core endpoint namespace is: This means it is reserved for core endpoints. Similarly, you may come across plugins that have a namespace. You should probably not add endpoints to a previously used namespace unless the data is specific to that plugin. Think of namespaces like you would with class or function names; they need to be unique. If you are creating endpoints, then #wordpress #smallbusiness #entrepreneur

https://managewp.org/articles/11405/wp-api-endpoint-namespaces

No comments:

Post a Comment