I'm trying to build an API which can be used to update some master data in my app. It contains various drop-downs for city, country etc. Whenever I add new data in these drop-downs, I need the apps to hit this API once a day and get the latest data. Also, if the API is requested older data (from older apps), it should be able to return such data based on some date query parameter.
What's the best way to create such an API?
Also, the API needs to be RESTful and will be exposed to Android/iOS environments.
API should be able to return so based on some date query parameter.
You can use two columns created_at and updated_at in you tables schema. So how can this will useful for your situation:
Whenever some one hitting api without date parameter, you are return all data which are created before current time.
Whenever some one hitting api with date parameter then you can return data which are created before value of date parameter.
Obviously you have to write complete logic for this at server side
end.
Please explore one of the Mobile Backend as a Service (mBaaS) products for your long term needs.
Here are some players:
BaasBox: Open source backend
Backendless: Allows
developers to have an instant backend without writing server-side
code.
Apigee App Services: provides a lot of free storage, push notification, analytics etc.
Appcelerator: An BaaS targeted at the Enterprise audience.
For the short run you may want to try https://www.webscript.io/ to embed some quick javascript code to return the JSON response for you.
I would put a spin on #Santanu's suggestion of using BaaS. I would recommend using a BaaS during the development phase of your project.
When the iPhone and Android Apps have been developed and tested, replace the Baas-based server components with a in-house built RESTful server.
This approach has a couple of benefits. It lets you divide the effort into two distinct parts: the client changes to your product, and the building of your server component.
I assume your company's current expertise lies in App development, so it should be easier for you all to upgrade your applications to use the BaaS-based APIs.
It will also be much easier to reiterate and refine your data components and models using a mature BaaS server.
With Apps using data requests to populate the drop-downs from a BaaS-based RESTful API, and stable working data models and data sets hosted in the BaaS servers, it will be much faster to start building your own RESTful service.
When you run into issues, you will be confident they are in the server side code. You can run A/B tests with the same Apps against two versions of the server and ensure the client experience is the same.
You could continue to use the BaaS Server for rapid prototyping and developing API extensions.
Related
I use two independent eCommerce platforms that don't officially support communication with one another, however, both have exposed REST API for managing products, orders, etc.
My question is: how can I leverage their APIs to allow the two platforms to exchange data?
Neither platform offers a workspace to code API calls and execute on retrieved records, so I don't understand how this scenario fits in the client server model.
Would this require a third node to be set up to act as the client with each of the eCommerce platforms acting as servers?
If so, then I surmise that this client would need to, for example, perform a GET request from Platform A, store the retrieved records in a database, then perform a POST to create the records in Platform B.
If my above understanding is correct, can anyone please advise on a platform/service with which this functionality can be built and managed? Is Postman what I'm looking for?
I'm still new to web API development, so please excuse my ignorance.
Any help would be much appreciated.
Thanks
I'm working on a project that consists in an python script that get data from an API and calculate things based in this data. The goal is to get this calculated information to a website. I was thinking in doing something like running this code in the same server as the website host server and posting the data generated in a database, then the website would get the information from the database and display it in the website. However, the front-end developer that is working with me said that would be a better option to develop a REST Api that would return to the website the data calculated in the python script. Does it makes sense to develop an API that will only be used internally? Wouldn't it be another unnecessary factor of complexity, since the data could be calculated, stored and retrieved form the host server without any API?
I'm confused about Firebase and serverless in general, as I was just introduced to this concept recently (note that I'm still studying computer science and I'm just exploring on my own now).
In the past I've been part of a project that had the following structure:
Front End in a Single-page-app
Back End built as a REST API
Now let's say I want to build a product, that might have a website and mobile apps. It also has to have backend logic as there are accounts, objects owned by users, and possible integration with a payment service.
What I initially expected from this, before knowning about serverless, is that you build a backend using something like Go (was my case), where you handle all the database data and third-party integrations, build a front end with something like Vue, and then use the backend's REST API to communicate between both of them.
Is this still the case with serverless? Do you build the whole backend server code, or does it work in another way?
I don't need/want you to explain all of it to me. I just need some insight on what is done and common so I can investigate further.
I need to connect Salesforce to an external database we have, and constantly keep both the database and salesforce updated in as close to real time as we can get. I have tired Google searching possible solutions, but nearly all of them have been outdated by over a year. Any ideas?
Thank You!
Depending on your exact scenario it is quite difficult to give you a proper answer.
However off the top of my head I would suggest two Salesforce products.
Salesforce Connect
https://www.salesforce.com/products/platform/products/salesforce-connect/
Salesforce Connect allows you to connect to various data sources and turn the tables / objects of that data source into a SObject. For example MySQL, Microsoft SQL Server, Oracle etc. There are limitations and thus it would be better to talk to a Certified Architect about such an implementation.
Heroku Connect
https://www.heroku.com/connect
Heroku Connect allows you to connect a Heroku data source with a Salesforce Object. The sync is not immediate but there are quite a few customisations inside the product to make the sync as "live" as possible. There are limitations and thus it would be better to talk to a Certified Architect about such an implementation.
Salesforce Connect has limitations.. It's good for presenting data via the interface, but if you need to act on the data and report on the data it might not be the best bet.
For close to real time hand coded sync, look at the streaming API, or using Salesforce Platform Events.
If you want to use an ETL tool, my organization has had decent luck with DBAmp, which is a Sql add on product and fairly inexpensive as compared to a lot of ETL tools ($1625 annually.) http://www.forceamp.com/ We're able to replicate the entire SF database offline in SQL with DBAMP, push changes to the offline Sql copy and upsert changes. It's also a good backup solution via offline full data copy. We got very good support from them as well when we encountered challenges.
Hope this helps.
Not sure if you are syncing one object or multiple objects but there are a few options that you have.
You can try the salesforce provided features Salesforce Connect which allows you to view and update data from your external source In salesforce but there are limitations with reporting and other considerations you should consider.
If you make use of Heroku, Heroku Connect is your best bet
You can also use a middleware ESB solutions like MuleSoft which can orchestrate keeping data in sync across multiple data sources and do batch loads, but depending on how often changes you want to keep an eye out for api limits for inbound calls to salesforce.
You can roll your own solution where you can use Outbound Messages in workflow (or triggers that initiates an apex class that calls out, but that is more cumbersome and you have to do custom error handling and retry logic which you get for free using outbound messages) to send changes from salesforce to your homegrown service that writes to you database and have you homegrown solution write back to salesforce using the soap or rest api. That would probably take you some time to build. You would also still need to be aware of API limits depending on how many updates are made on the non salesforce side.
You crate a Canvas App which displays data from your DB in Salesforce as a Tab and hook it up via SSO so users are auto logged in. But again there would not be reporting, or any salesforce features that you can take advantage of.
But I really think that you should spend some time to determine what system is your source of truth because that would determine how the data should be synced. You should also investigate if you really need the sync to be realtime or near realtime, or if you can manage with something like an hourly true up on the system that is not the source of truth.
I'm developing an iPad app, which is connected to a Django Server on the backend. The server mostly is just a REST API on top of a database (this is done with TastyPi, for the record).
I'm trying to understand the best way to develop this, since I'm new to iOS.
So a few related questions:
Is there a library that simplifies the work of making "models" in your code that mirror the models on the server?
I would imagine something like Django's ORM, which allows you to define objects in Objective C , that are mapped 1-to-1 to objects that the REST Api gives you.
This library could abstract all of the cache-ing and converting between local objects and the objects on the server.
If this kind of library doesn't exist, are there a set of best-practices for this type of project? For example, should I even have local objects that reflect the DB? Should I have one class which takes care of all the code that deals with the API, or should I write the requests in the many different objects that are part of the API?
In short, where can I learn the "right" way to code iOS apps backed by a REST Api exposing a database? Preferably a tutorial, rather than looking at existing projects' code.
1) For ORM, iOS has Core Data that lets you build your entity and work with objects rather than SQL statements like SELECT, LEFT JOIN etc.
Don't know about others, but this is how I usually do it:
1) App makes a HTTP POST request to the Web Service using a library like ASIHttpRequest library. (Note, for the backend, I wrote my web service using Symfony web framework)
2) The app sends back the JSON response.
e.g.
{
data
{
name: bob
age: 20
}
}
3) Parse the JSON using a JSON parser like JSONKit or the one provided by ASIHttpRequest and convert the JSON server response into a NSDictionary.
NSDictionary *data = [[request responseString] objectFromJSONString];
4) Now whether to store the data on the app or not depends on the nature of the app. If the app is to do searches for local restaurants, then you probably don't want to keep a local copy of the returned result, since the nature of the app is to search for restaurants.
However, if you got like a login system that downloads user's home work from their account, then you would likely store these data on the device locally.
This is where Core Data comes in, you build your model that replicates the server model and you do a simple 1 to 1 mapping between server and client models.
Hope that helps.
Check out Rest kit
RestKit is an Objective-C framework for iOS that aims to make
interacting with RESTful web services simple, fast and fun. It
combines a clean, simple HTTP request/response API with a powerful
object mapping system that reduces the amount of code you need to
write to get stuff done.
It also supports persisting remotely loaded objects directly back into a local store
The Parse.com api is RESTful, and takes care of a kajillion hours of boilerplate code construction for a database. I don't work for them, but I do like the service.
For #1, helios.io does the trick. From the docs at github,
In order to keep your data model and REST webservices in sync, you can link it to your helios application:
$ helios link path/to/DataModel.xcdatamodel
This creates a hard link between the data model file in your Xcode and Helios projects—any changes made to either file will affect both. The next time you start the server, Helios will automatically migrate the database to create tables and insert columns to accomodate any new entities or attribute