1.1 What is a REST API?
A REST API allows a user to interact with the server by creating requests and receiving responses. REST stands for REpresentational State Transfer and API stands for Application Programming Interface. A REST API is a type of API that follows a REST architecture.
There are six architectural constraints that all REST APIs follow:
Client-Server Architecture- this indicates that the client and the server are separate from each other and must be able to function independently.
Uniform Interface- the structure of the call and response must be uniform across all REST APIs.
Stateless- This means the server will not store a history of previous calls made to the server. Each call will be considered new.
Cacheable- all responses must be cacheable.
Layered System- It is possible to have many servers. The client should not be able to tell if it is connected to the end server or an intermediary server.
Code on demand (optional)- the server may return executable code to the client.
These constraints are intended to make the REST API fast and reliable.
Definition: |
A client is defined by the Merriam Webster dictionary as a computer in a network that uses the services (such as access to files or shared peripherals) provided by a server. |
How does the REST API interact with the FME Server?
The REST API acts like a intermediary directly communicating with the FME Server and relaying the responses back to the client. You can see the relationship between the FME Server and the API in the diagram below:
Diagram of the relationship between the FME Server and the client
The REST API reads the call which is composed of the HTTP Method, URL, and the body of the call. The FME Server will respond with JSON.
Definition: |
JSON is a common data interchange format that has become one of the leading choices for supporting web sites and mobile device applications. For more information see the Tutorial: Getting Started with JSON article on the Knowledge Center |
What is the purpose of a REST API?
The REST API allows a user to interact with the FME Server without the use of the FME Server Graphical User Interface. This enables the user to create web applications that allow a client access to the FME Server without ever having to log in or directly access the server. It can also be used to automate processes within FME Server. For instance, an FME user can create a script to run health checks regularly on the Server.
Ricky RESTless says... |
I use the FME Server REST API for everything! From sending notifications to running jobs and viewing job history. It seems like the possibilities of the FME Server REST API are endless. |
Examples of web applications created with the REST API
If you are curious about all the possibilities of using the REST API, please visit the FME Server Demos. The FME Knowledge Center has live demonstrations that display the vast capabilities of using the FME Server and the REST API.
The example below demonstrates how to gather data from the FME Server using a web application. It allows a user to request public transit information within an area specified by the user and you can view this Live Online demo.
This demonstration allows the user to draw a polygon on an area. Then, the user will set the parameters for the call, this includes which layers to download and the coordinate system. The user hits request data and will receive a zip file with the requested information. If you wish to rebuild this demo, visit the Data Distribution with Web Maps demo.
Image of a web mapping application from the FME Server Playground