Do you mean a JSON web API? If so , sounds like you're talking about
a Service Oriented Architecture.
To be honest, the *easiest* JSON APIs i've ever written were in Pylons/
Pyramid. You have full control of the request, and all you need to do
is return a dict from a view/handler that is decorated to render
json(p).
In terms of your app structure:
1) The @view_config decorator is pretty powerful and lets fine-tune
the scenarios in which a view is rendered. ( I wanted to write
'context' in there, but there is an argument to the constructor called
'context' with a pyramid-specific meaning ). You could conceivably
have a single codebase that just responds with different templates and
available methods.
2) I wouldn't have Pyramid call a Web API to process the data quite
yet. That's typically something you do at scaling time because it has
quite a bit of overhead in administration and maintenance. I'd
probably just construct the public web-based API methods to wrap some
helper functions into a package in app/lib that does the real work --
and which the webapp directly calls as well -- having them return
dicts. when you're ready to scale, you just have to change where you
request the dicts -- or how they're generated.
There are a handful of posts in this list and stackoverflow that talk
about customizing views for devices.