YourSiteAdmin API

  • Introduction

    Here at YourSiteAdmin we like to make things as easy as possible for you as a website owner. We have plenty of tools within the admin area for you to edit the content, structure, settings and images onm your site. But how do you get this information to your site (if it has not been hosted and built by us)?

    The answer is simple. An API. And we have one all ready to go that is quick and easy to install and use. First things first though, if you're new to web development, what is an API and how would it benefit you?

    What Is An API?

    An application programming interface (API) is a specification intended to be used as an interface by software components to communicate with each other. An API may include specifications for routines, data structures, object classes, and variables.

    from Wikipedia

    In laments terms this basically means that it is a piece of script (in this case PHP) that requests content from an external source and manages the response accordingly. Our API is used to return all the information you have put into your site from anywhere (as long as it is a server that can run PHP, preferably greater than 5.3).

    In the image above you can see the process by which information gets from your accout here on YourSiteAdmin to your website. If you work backwards it's a little easier to understand:

    1. A client visits your website and the browser requests a page from the server
    2. Your web server uses our API script to contact our API with certain credentials to return the information required by the client.
    3. The API end point here at YourSiteAdmin looks at the request, pulls together all the information requested and sends it back.
    4. The API script on your web server then gets the response and handles it accordingly.
    5. Some processing of the response and then it is output to the original client request.

    You may be thinking that this is a long process, but the server hosting YourSiteAdmin is very fast and will return most simple requests very quickly indeed. The API script we give you also implements caching, which stores a "snapshot" of the response for the requested time and then, rather than requesting fresh data from the API everytime it will look for content in the cache on your server first and only use the API if there is no data available.

  • Using The API

    In order to use our API you will need a couple of things. Firstly, an API Key. This can be generated in your account settings page. If the API Key box is empty click generate at the bottom of the page. You can also re-generate an API Key by clicking "Generate", but don't forget to change the API on your site otherwise you won't be able to access the API!

    Once you have an API Key you will also need to know the ID of the site you would like content for. The ID of the site you are currently editing is . This ID will need to be added to the config in the script we'll give you below. There are instructions in that script too telling you where to put this information.

    We also require that the server your site is hosted on is currently running cURL. cURL is a way for one server to contact another for various purposes. For more information click that link.

    The API Script