yahoo new weather api url not working?

Hello team,

Please help me to create new yahoo weather API and help to Create a proxy to find sunset time for a given city

The city name should be passed in request url. (Ex: http://myproxyurl.com/sunset/city/Bangalore)

Solved Solved
1 12 2,311
1 ACCEPTED SOLUTION

sidd-harth
Participant V

Hi @pratheek hipparagi, PFA proxy for your reference. I have tried to cover most of the point,

yahoo-rev1-2018-06-05.zip

  1. I am passing two query params in request URL, city & format
  2. Extracting them & forming the query required for Yahoo
  3. Used APIkey policy in the header
  4. Used Quota with an ApiKey identifier & allows 10pm
  5. Instead of using KVM for backend URL I have used Target Server (Why do you want to use KVM for backend URL?)
  6. there is no need to use JSON-XML policy, because the Yahoo API does it for us.
org-env.apigee.net/weather/v1?format=json&city=Hyderabad
org-env.apigee.net/weather/v1?format=xml&city=Chennai
use a Header with valid APIKEY

This is one approach, we can implement the same in various approaches like,

  • we can pass city dynamic values within {uriParams}
  • we can pass format values using Content-type, Accept Headers.

View solution in original post

12 REPLIES 12

What did you try? What problem did you see?

Hi Dino,

I created a sunset proxy using Existing URL https://query.yahooapis.com

The city name should be passed in request URL.

(Ex: http://query.yahooapis.com/sunset/city/Bangalore) - The city name should be dynamic We can pass any city name.

The api proxy should support both JSON and xml response. If request header called Accept is text/xml then it should return json response. If it is application/json then also it should return JSON response.

Ex: JSON: { "city": "Bangalore", "sunsetTime": "6.42 pm", "created": "2018-05-30T11:15:06Z" }

Please help me to resolve this and suggest me the conditional flows to be applied.

Thanks & Regards

Pratheek

Pratheek, I'm not clear.

you specified " https://query.yahooapis.com" but that URL doesn't do anything. It returns a a page that reports that it is an internal YQL URL.

You also specified this url: http://query.yahooapis.com/sunset/city/Bangalore , which ... doesn't make sense to me. What is that?

Can you take a step back? Remember: I know NOTHING about what you are trying to do.

Explain as if I am not looking at your screen, and as if I am not inside your head. (because I am not)

That you are using yahooapis in particular is irrelevant.

I think you want to

  • create an API proxy
  • the proxy should accept dynamic values in a url segment. This will be the city name. The inbound URLs will look like https://myhostname.apigee.net/sunset/city/Bangalore or https://myhostname.apigee.net/sunset/city/Mumbai , and the proxy should extract Bangalore or Mumbai. To do this, you can use ExtractVariables and use the URI. (check the documentation for this policy and pay attention to the basepath.)
  • the proxy should do "something" with that city name. I don't know what. I think this city name needs to be passed back to a different service, probably something hosted in yahooapis.com, but as I said, that is irrelevant. I don't know anything about YQL, and I don't need to know. The key is: the backend system (which in your case is yahooapis) exposes an interface, a calling convention. Your proxy must form the request to that backend according to that calling convention. The Apigee API proxy can extract the city name from the dynamic url segment, and map it into "something else". But you haven't told us what that something else is. If you can you explain what the backend expects, I can explain how to create that kind of request in Apigee Edge. What does the request to the backend look like? Be specific! The method, the shape of the URL, the headers, the query params, the form params, etc.
  • I think after the response is received from the yahooapis thing, you want to manipulate the response. Maybe you want to filter the fields, and maybe you want to transform to JSON or XML. I'm not clear on this either. Can you explain specifically?

Hey Dino, I m sorry for not giving exact information needed,As a beginner I need to do a scenario can you please help me out please specify me all the actions/methods to do.

1.I want to Create Api proxy

2.URL Should return weather condition of a given city

3.The city name should be passed in request parameter. (Ex: http://myproxyurl.com/weather/v1/find?city=Bangalore)

4.The api proxy should support both JSON and xml response.

5.Pass API key in http header called apikey.

6.The api should allow only 10 requests per minute for a given client.

7.The backend url (https://query.yahooapis.com) should be configurable in KVM(key value Map).

8.And help me to create postman scripts for testing.

9.YQL-Query [ https://query.yahooapis.com/v1/public/yql?q=select item.condition.text from weather.forecast where woeid in (select woeid from geo.places(1) where text="Bangalore")&format=json]

Thank you,

pratheek

sidd-harth
Participant V

Hi @pratheek hipparagi, PFA proxy for your reference. I have tried to cover most of the point,

yahoo-rev1-2018-06-05.zip

  1. I am passing two query params in request URL, city & format
  2. Extracting them & forming the query required for Yahoo
  3. Used APIkey policy in the header
  4. Used Quota with an ApiKey identifier & allows 10pm
  5. Instead of using KVM for backend URL I have used Target Server (Why do you want to use KVM for backend URL?)
  6. there is no need to use JSON-XML policy, because the Yahoo API does it for us.
org-env.apigee.net/weather/v1?format=json&city=Hyderabad
org-env.apigee.net/weather/v1?format=xml&city=Chennai
use a Header with valid APIKEY

This is one approach, we can implement the same in various approaches like,

  • we can pass city dynamic values within {uriParams}
  • we can pass format values using Content-type, Accept Headers.

Hi Siddharth,

I tried using your zipfile in apigee but I am unable to deploy the bundle as I get the error "Target default has invalid server reference yahoo_url".

Could you tell me why that is or help me figure out a solution?

Thanks.

That proxy uses a target server. It would require an extra setup step on your side to get it to work.

Please find attached a simpler version of the same. It will work without the target server setup. apiproxy-yahoo-weather.zip

Thank you so much. This version works great. I just have one question. I am new to Apigee so I am not sure where the API Key verification takes place and is there a way for there to be a list of users and only a subset can access the API depending on whether they have a key or not. I wonder if I am being clear enough in what I mean and if I should be starting a separate thread for my queries.

Rohan

Your original question was about the Yahoo Weather URL. This question is about API key verification. Generally in that case, you should ask a new question.

You can search around (your question has been asked before), or check youtube. or ask a new question. I'll answer it.

shawkyfoda
Participant IV

As apigee-edge-deploy-maven-plugin uses this api as a sample, I expect that the maven project in git should be updated also. please correct me if i'm wrong

Hi @Shawky Foda, please create a new question and elabrate what you are trying to do.

7564-untitled.png

I totally feel your frustration with the Yahoo weather API URL acting up. He's been working really weirdly lately. As for the sunset time proxy, just make sure you pass the city name in the request URL, and you'll be good to go. If you're looking for a reliable alternative, I'd recommend checking out worldweatheronline.com. Their API is perfect for professionals like us who need accurate weather data for our businesses, web, and app development projects. Anyway, I wish you all the best and good luck.