Showing posts with label PracticalAPI. Show all posts
Showing posts with label PracticalAPI. Show all posts

Wednesday, May 27, 2015

Creating a RESTful API starting from a SOAPish one - Part 1

Now that we understand why APIs are important and how they evolved, let’s go a level deeper with a practical example. In the next several posts, we will cover how EchoSign (now Adobe Document Cloud eSign services) REST APIs were created from scratch maintaining the REST API Design principles while ensuring maximum compatibility with SOAP APIs to provide easy transition to the customers that were using them extensively. Keeping SOAP API as a reference has two benefits. Firstly, if you have an existing SOAP API, this provides a suggested approach on how you can easily transition to a REST API. Secondly it allows us to clearly notice the difference in paradigms between SOAP and REST in a real world example.

Here is high level diagram of the REST API resources in EchoSign and how they are connected


And then straight to the 20,000 feet dive. Following is the first set of the 1<>1 mapping of SOAP API methods (Document and Status) and REST endpoints of EchoSign, the Adobe Document Cloud eSign service. We will talk about these through the blog but many of you have asked for this list before and seeing the end result makes several of us happier

For reference, you can find the latest version of the EchoSign SOAP API here

And the REST counterpart can be checked-out here.


SOAP API method
REST end-point
Comments
Transient Document - REST allows documents to be used for creating agreements, widgets and library documents to be uploaded separately and return ids to be used in respective creation calls
-NA-
/transientDocuments, POST
Uploads a document and return an id valid for 7 days
sendDocument
/agreements, POST
SenderInfo is represented through x-user-id/email. Files are specified through /transientDocuments above
sendDocument
Interactive
/agreements, POST
InteractiveOptions can be optionally specified for the Interactive behavior
sendDocumentMegaSign
-NAY-

createLibraryDocument
/libraryDocuments, POST

createLibraryDocument
Interactive
/libraryDocuments, POST
InteractiveOptions can be optionally specified for the Interactive behavior
sendReminder
/reminders, POST

removeDocument
-NAY-

cancelDocument
/agreements/{agrId}/status, PUT
Update the status to CANCEL
rejectDocument
-NAY-

replaceSigner
-NAY-

delegateSigning
-NAY-

notifyDocumentVaulted
-NAY-




In SOAP API, getDocumentInfo, getDocuments, getAuditTrail etc work on documentKeys which can be an agreement, widget or library document ids. REST API demarcates these as separate resources (cleaner design) and hence based on the kind of resource you are working on, there is a corresponding /libraryDocuments,  /widgets to these .Eg, /widgets/{widgetId}, GET will getDocumentInfo for widgetId
getDocumentInfo
/agreements/{agrId}, GET

getDocumentInfosBy
ExternalId
-NAY-

getDocuments
/agreements/{agrId}/documents, GET
REST returns a list of document ids that can be provided to the following end-point to get document stream
-NA-
/agreements/{agrId}/documents/ {docId}, GET
Returns the raw stream of the file. More efficient/compact than base64
-NA-
/agreements/{agrId}/ combinedDocument, GET
Returns raw stream of combined agreement. Can also request to attach audit trail/supporting docs
getDocumentUrls
-NAY-

getDocumentImageUrls
-NAY-

getSupportingDocuments
/agreements/{agrId}/documents, GET
Can also specify content format
getFormData
/agreements/{agrId}/formData, GET
Returns CSV file stream
getSigningUrl
/agreements/{agrId}/signingUrls, GET

In the next post, we will cover the remaining set of EchoSign SOAP APIs including the User and Widget methods

Wednesday, January 7, 2015

The route to your favourite destination

Ever wondered how your favourite Cab Service or GPS software finds directions using Google from your phone or tablet. Yes, you guessed it correct - using Google Direction APIs. Google has made a lot of it's services like maps, search, gmail accessible to us through APIs and playing with it comes for free with your Google account. Want to try it yourself? Open the following link in your browser and see how Google Direction API responds with the direction to the coolest new year destination -  Goa, India from Mumbai, India


The link URL is called API Request and the what you get to see in the browser window is called the API response. The notation that you see is called JSON and is made of key-value pairs. For instance "end_address" is a key and it's value is "Goa, India". See how it shows you the distance (603 km), the duration (9hrs 30 minutes) and step by step directions. It also identifies the state of Mumbai i.e Maharashtra. This response is what all those Mobile Apps Use to show you the route details

Feel free to try you own choice of locations by just changing Mumbai to your start place and Goa to end place. Note this uses my Google API key (you can get one for free too) which works only 2500 times a day, so if it fails for you, be the first one to try tomorrow