0

I am developing a mobile app on Android. I download a lot of information from the backend via REST API. For example for obtain the information about a contract I use the api the following request:

GET /contracts/01212314.json

It return a json with many fields

{
"conto_contrattuale": "01212314",
"intestatario": "Dennis D'Amico",
"utilizzo": "COTTURA + PROD. ACQUA 7 GG",
"codice_settore_merceologico": "E1",
"settore_merceologico": "ELETTRICITA",
"codice_societa_vendita": "Z016",
"societa_vendita": "Estra Energie S.r.l.",
"fornitura_indirizzo": "Via Palermo",
"fornitura_civico": "20",
"fornitura_precisazione": "Rosso",
"fornitura_cap": "59100",
"fornitura_comune": "Prato"
"rid": false,
"fatt_elettronica": true,
"fatt_email": "andrea.bettarini@devise.it",
"fatture_scadute": 1,
 }

But I am only interested to the field : "fornitura_indirizzo" I can't modify the backend and the API. So I think to create a new middle backend that fetch the info from the actual backend and exposes a call only for the field "fornitura_indirizzo".

How can I do? Is it possible on google cloud platform? and is it free?

Thank you for your consideration.

javierZanetti
  • 288
  • 4
  • 17

3 Answers3

0

You can put a file on your server that fetches the data en then recreates a partial array and echo that in json. Example:

     $contract = Json_decode("/contracts/xxxx.json", true);
     $needed_info = $contract["fornitura_indirizzo"];
     Echo json_encode($needed_info);
Zerre
  • 105
  • 2
  • 2
  • 7
0

I can't access to the server and modify. I can only send request.

javierZanetti
  • 288
  • 4
  • 17
0

I apologise if I misunderstand your goals here, but why bother with creating this new back end for your app. You could simply call the existing back end and ignore the unneeded information. Either way, that existing back end has to send all that info somewhere for every request your mobile app performs. You're also adding more latency to the request since it has to go through your back end first.

I can see this being worth it though if your goal is to minimize the data downloaded by the mobile app when it does a request.

Matt Welke
  • 1,441
  • 1
  • 15
  • 40