Our API integrations offer advanced functionality rarely available from the native endpoint to make building faster and simpler. Features include: Normalized methods and calls across all APIs (ex. Convert SOAP/XML to REST/JSON) Webhooks and polling out-of-the-box; Standardize authentication flows to avoid endpoint nuance.
- OpenID Connect 1.0 is a simple identity layer on top of the OAuth 2.0 protocol. It allows Clients to verify the identity of the End-User based on the authentication performed by an Authorization Server, as well as to obtain basic profile information about the End-User in an interoperable and REST-like manner.
- Browse 7+ Best Notes APIs available on RapidAPI.com. Top Best Notes APIs include Evernote, Wunderlist, OneNote and more. Sign Up today for Free!
I’ve been playing for a while with Evernote and their API, which I find rather simple and effective (well done, guys!) — and as such on a few pet projects I have started considering moving the storage to Evernote itself. The beauty of using Evernote is that the storage is already structured for you in an XML document, with a syntax which looks a bit like HTML — that means that you can parse it as you would with any XML document, but also you can use occasionally a HTML parser to achieve the same!
One of the areas where I started considering Evernote is storing lists — if you look at your apps, I’m sure that every now and then you find the need to simply store some form of lists, and in such cases a lot of times we end up re-inventing the wheel, using TEXT
fields in MySQL, plain text files in S3 and all sorts, all of which needing coding, maintenance and so on. Rather than doing that, I thought instead of using a dedicated service like Evernote and more recently UbiquiList. UbiquiList, as it turns out, is actually specifically designed to deal with just lists — and it’s growing rapidly into a nice tool for that! I’ve spoken to Ian too (the coder behind UbiquiList) and as I understand they’re working on a REST API for it, so expect soon a new post in these series about using UbiquiList for the same; meanwhile though I’m only going to touch on using Evernote for the purpose of storing lists in this article.
So, the idea is simple: you need to store a list of “things” for your user — nothing fancy, just a random list of strings, for the purpose of your app. You can of course use a simple TEXT
field in MySQL, and make the convention that each line is an item in your list….Unless of course your strings contain new line characters, which you might have to escape… Or switch to something like XML… And maybe these are getting now bigger and growing the size of your database unwantingly …. So let’s move it to S3… And you can see how this simple problem can spiral quickly to a complex one! Or you can use Evernote 🙂
The rational behind it is simple — we move all the retrieving and saving to Evernote in exchange for a very simple API, where we just retrieve a note and its content. To retrieve the items in the list, knowing that Evernote uses its own markup similar to HTML, we’d be just simply parsing the content and look for <li>
elements only — inside those are our list items.
Now you can argue that parsing XML and traversing it can be a still daunting task in Java — but here’s a little trick: use JSoup! JSoup allows you to use a JQuery like expression to retrieve the elements you want from a document, which means that our code for retrieving our list items becomes something as simple as this (look at the App.java file, in extractListItems
function):
From there on, you can interpret these items whichever way you want and treat them as separate list items, without the headaches of escaping new lines, storing and retrieving from S3 and so on.
A few notes on this (very very simple) app:
- as per usual, the code for it is in GitHub: https://github.com/liviutudor/EvernoteTestList , it’s mavenized and it relies on the Evernote API as well as JSoup (the only other dependency is JUnit for unit testing).
- by default, the code uses the Sandbox Evernote environment — however, change the
SERVICE
constant in App.java to point it toPRODUCTION
if you are willing to run this against your own live Evernote account - in order to run it, you will need a developer token from Evernote — you need to save this in a file called
.evernotetestlist
in your home directory as the app will be looking for this on startup and reading the token from there. - For the purpose of my testing, I have used this sandbox note: https://sandbox.evernote.com/shard/s1/sh/fc1e6790-b901-4234-ae70-83294c4d9487/d47178851d453bc014bc6febfe4df036 which looks like this:
As such, when running the app, it will select only the following items and interpret them as list items:
As you can see, the app simply merges ALL list items into one big list, however, there is nothing to say you cannot change the code to support multiple lists, or indeed change the storage to use a different tag (<div>? <ul> ? <ol>?)
I’ll hopefully come back soon with a follow-up on using a 3rd party to store lists in an app based on UbiquiList.
More from my site
Web applications often have tables of data, whether it's the list of items for sale on Amazon, or notes in Evernote, and so on. Usually, users of the application are going to want to filter the results or sort through that data in some way.
If the dataset is pretty small, maybe a few hundred results, the API can return all the data at once and the front end will handle all the filtering, and no more API calls are required. Most of the time, however, the data could consist of tens of thousands to millions of rows, and it's better to just get the data you need from smaller API calls as opposed to trying to request a million results every time the page loads.
Evernote Rest Api Tutorial
Recently, I made a backend API for some list endpoints, and implemented filtering, sorting, and pagination. There's not really a set standard for creating these types of endpoints, and almost every one I've come across is different in some way. I made a few notes on what made sense to me, so this resource could be helpful for someone who is working on designing an API.
Goals
In this article I'll make an example API endpoint and SQL query for various sort, paginate, and filter APIs, with users
as the table for all examples.
Evernote Rest Api Login
Contents
Response
When using any pagination or filtering in an API, you're going to want to know how many results you have, how many results there are total, and what page you're on.
From there, you can discern that there are 20 pages with total_results / results_per_page
and anything else you might need for the front end.
Pagination
Pagination is how you move between the pages when you don't want to retrieve all the results at once.
- Page and results per page are required inputs
- For the SQL query,
offset
is equal to(page - 1) * results_per_page
Sorting
Sorting allows you to order the results by any field, in ascending or descending order.
Ascending vs. Descending
I always forget what ascending and descending mean for alphabetical, numerical, and date-based responses, so I wrote this up for reference.
Type | Order | Example | Description |
---|---|---|---|
Alphabetical | Ascending | A - Z | First to last |
Alphabetical | Descending | Z - A | Last to first |
Numerical | Ascending | 1 - 9 | Lowest to highest |
Numerical | Descending | 9 - 1 | Highest to lowest |
Date | Ascending | 01-01-1970 - Today | Oldest to newest |
Date | Descending | Today - 01-01-1970 | Newest to oldest |
Single column
If you only need to sort one column at a time, you could put the column name in sort_by
and the sort direction in order
.
Multiple columns
If the ability to sort multiple columns is required, you could comma-separate each column:order
pair and put it in one sort
parameter. This could also be used for a single column if you prefer the syntax.
Filtering
Filtering is by far the most complex of the three. There are several ways to handle it. Some APIs will use a POST
and pass all the data in the body of the request for searching. This might be necessary for advanced searching in some situations, but a GET
is preferable.
Some API will attempt to put everything on a single filter
parameter, like this:
In Evernote
However, this will have to be URI encoded.
I've opted for treating each parameter as a column in the database.
String (exact)
Exact search by a single column.
String (exact, multiple)
Depending on how you want to handle the API, multiple options for a single column can be handled in different ways. If splitting by comma isn't an issue, it might be the easiest. You might also just want to repeat the parameter name or use a custom delimiter.
Some systems might require using []
for multiple parameters of the same name, and some might now allow []
, so I provided both options.
String (partial)
Often, searches are expected to be partial, so that when I look for 'Tan' it will show me 'Tania' and 'Tanner'. The solution I liked was using like:Tan
as value as opposed to modifying the parameter (such as first_name[like]=Tan
).
Number (exact)
Exact number search on a column.
Number (greater than)
Similar to like:
, you can use gt:
to handle greater than. Adding the option for gte:
(greater than or equal) is also an option.
Number (less than)
Evernote Rest Api Json
Same with lt:
for less than lte:
for less than or equal.
Number (range)
Evernote Rest Api Download
If you need a range between two number values, using [and]
in between them could be one option. This one could get complicated, depending on if you want to allow both greater than and greater than or equal, or other options.
Date (range)
If you need a range between two dates, you can use start
and end
, or since
and to
.
Conclusion
These examples are pretty simple and cover basic use cases. If your API is very complicated, you might need to change it up to add more options, particularly with ranges, and various combinations of 'and' and 'or'. Hopefully this will be a helpful starting point!