
What language/framework would be suitable for a new lightweight API project? - dustinfarris
I want to write a simple API to interface directly with Elasticsearch, almost to the point of being a proxy.  I have extensive Python&#x2F;Django experience, but I&#x27;m open to learning something new.  Since this is pretty much going to be a CRUD API with some authentication logic, Django feels like overkill.  I&#x27;m looking at learning Flask, or perhaps something non-Python.  Any suggestions?
======
amirmansour
If you are keen on learning something new then I definitely recommend looking
into Go. It will be time well-spent, and you can use the minimal Gorilla web
toolkit ([http://www.gorillatoolkit.org](http://www.gorillatoolkit.org)). It's
a toolkit and not a framework, so you can just use the parts that you need,
and that's nice way of staying "lightweight."

With that said, I wouldn't brush off Python as a possible choice. Here are
some small/lightweight Python web frameworks in addition to Flask
([http://flask.pocoo.org](http://flask.pocoo.org)):

1\. Bottle ([http://bottlepy.org](http://bottlepy.org)). It's a one file
module and has no dependencies.

2\. Web.py ([http://webpy.org](http://webpy.org)). The "anti-framework." Very
simple.

3\. CherryPy ([http://www.cherrypy.org](http://www.cherrypy.org)). Another
minimal framework that comes with its own WSGI server.

All the frameworks mentioned above are stable, mature, and used in production.
With that said, any good API these days needs authentication, authorization,
and rate-limiting. To get these standard things done from the start you should
look at fantastic Django Rest Framework (at least don't ignore it). If you do
use Django, then you can also use Haystack
([http://haystacksearch.org](http://haystacksearch.org)) to easily work with
Elasticsearch.

It's hard to give detailed suggestions without knowing the application you are
trying to build, but I hope you find this helpful.

~~~
dustinfarris
Thanks for the answer, and thanks for the links. I gave DRF+Haystack serious
consideration already—in fact, I built a prototype using these packages. The
reason I do not want to move forward with them is that they make the
assumption that you will be using Django's ORM and some sort of SQL store for
persistence with Elasticsearch bolted on top. My intention is to use
Elasticsearch exclusively. I also want to use the API with Ember.js, which is
difficult given the differing JSON format opinions between DRF and Ember.js
(see ember-django-adapter[1]).

I've also noticed that Haystack's owner has been inactive recently which
concerns me. This in itself gave me a reason to check out Elasticsearch's own
Python bindings[2] which aren't that scary after all.

I am looking at Gorilla web toolkit (thanks for the link!).

[1]: [https://github.com/dustinfarris/ember-django-
adapter](https://github.com/dustinfarris/ember-django-adapter)

[2]: [https://github.com/elasticsearch/elasticsearch-
py](https://github.com/elasticsearch/elasticsearch-py)

------
jimeh
I haven't used Flask (or Python) aside from one small hack project. It seemed
simple and straight forward enough, and very similar to Ruby's Sinatra
framework. Personally in Ruby I would most likely pick Sinatra, in Python I'd
pick Flash or something similar.

However if you wanna play with languages you're less familiar with, I'd
recommend Go, or Node.js.

Personally I find Go really interesting as it's quite different from the
languages I normally work in, and it's concurrency model makes it performant
without being a mindfuck.

Node.js is interesting as it's Javascript, but extremely I/O performant due to
it's evented nature, but that also makes concurrency a bit of a mindfuck at
times.

Those are my suggestions at least if you're itching to get your toes wet in
some new fun languages :)

~~~
dustinfarris
I actually went through the Golang quickstart before writing my original post.
It is very tempting, but I'm concerned it might be a long journey for what
should be a simple app. In your experience, how productive is Go at kicking
out basic CRUD APIs?

~~~
jimeh
I haven't built a full CRUD app myself, mostly some small hacked together
tools and various silly stuff. Personally though I did end up just
experimenting with basic stuff to get familiar with the language and tools for
a couple of evenings before I got anything even half-useful done.

So I'd say, if just want to get a simple CRUD API app out quickly, use Python
and Flask or something similar as it's something you already know well. If you
wanna use the CRUD API app as an excuse to play with new languages and
technologies which will hopefully lead to a expanded skill-set, then go for Go
;)

As for Node.js, if you already know Javascript, it'll fall about 30-40% of the
way between using Python that you know and Go that you don't know.

------
ivan_ah
You probably know about django-rest-framework, which I find to be absolutely
awesome. I wouldn't look further --- sooo much batteries the API will
practically write itself ;)

~~~
dustinfarris
I'm familiar with DRF, and yes, it is terrific. However, because I want to
interface directly with Elasticsearch, I am inclined to drop Django
altogether.

~~~
ivan_ah
I see. Then node might be a good tech to look into. It's very good for network
stuff. Here is an example of a `solr` proxy written by my friend:
[https://github.com/dergachev/solr-security-
proxy/blob/master...](https://github.com/dergachev/solr-security-
proxy/blob/master/solr-security-proxy.js)

------
timbuchwaldt
I would suggest node.js - it makes it really easy to not shoot yourself in the
foot. The async nature allows for concurrency, something you can't easily
archieve with e.g. ruby and python. And while you are at it, try out hapi.js:
[http://hapijs.com/](http://hapijs.com/) \- my favorite tool for writing
request proxies (which i do for a living :D )

~~~
tasubotadas
[https://www.youtube.com/watch?v=bzkRVzciAZg](https://www.youtube.com/watch?v=bzkRVzciAZg)

~~~
timbuchwaldt
:D Yeaaaah..I'd actually much prefer ruby or python... but it just doesn't
perform :(

------
mamcx
Do it in Python with django rest or flask or whatever. You have experience on
it.

When you have it nailed, try to do it in something else!

I have no experience with it, but what about elixir-lang.org? Everyone try GO
or Node. Be more brave and be more niche!

Also, I'm learning a bit of F#. Is so crazy, and is .NET. So, how about be
against the trends :)

------
brogrammer90
If you're just using HTTP auth then try Sinatra. You could probably whip up
something viable in 50 lines.

~~~
dustinfarris
Sinatra looks very straight-forward. Checking out the repo on GitHub now, and
it looks great! I will probably do some sort of token-based auth. The app will
eventually integrate with Ember.js.

~~~
anko
i don't know if this will be too confusing for you if you're new to sinatra,
but the new version of Kibana (which is basically an interface to
elasticsearch) uses sinatra, angular and grunt. Basically there are some grunt
tasks to package it up into jruby so the final app runs wherever java is
installed.

[https://github.com/elasticsearch/kibana](https://github.com/elasticsearch/kibana)

------
Mithaldu
If you feel like having a look at Perl, give this a try:
[https://metacpan.org/pod/Web::Simple](https://metacpan.org/pod/Web::Simple)

If nothing else you'll be introduced to a lot of programming concepts you'd
otherwise be unlikely to see.

------
cmrajan
I'd recommend Flask-Restful [https://github.com/twilio/flask-
restful](https://github.com/twilio/flask-restful) I've recently used in an API
project involving Elasticsearch.

------
meson10
If you feel like using golang. I have written this and been using this in
production for quite some time
[https://github.com/Simversity/gottp](https://github.com/Simversity/gottp)

------
phantom_oracle
Maybe this might help:

[http://python-eve.org/](http://python-eve.org/)

It is written on top of Flask and includes some batteries.

Could get a simple API up in 2 hours.

------
izolate
Hands down Node.js with Restify/Express.js. And this is coming from somebody
who loves Python (Flask, Pyramid)

------
fit2rule
Check out luvit:

[https://luvit.io/](https://luvit.io/)

Learn a little Lua along the way. Really great stuff!

------
mahouse
Flask is the way to go.

~~~
Sami_Lehtinen
Bottle is simple single file library for small APIs.

------
knappador
Flask.

------
Jahak
use php

~~~
dustinfarris
Can you elaborate?

~~~
pan69
[http://www.slimframework.com](http://www.slimframework.com)

[http://silex.sensiolabs.org](http://silex.sensiolabs.org)

