# City Weather and Examples

### Chainlink Functions Playground

First, go to [Chainlink Functions Playground - City Weather](https://functions.chain.link/playground/13f3c115-e8b2-4eca-9c59-275f03e3b310) and the source code will be loaded into the playground. Alternatively, you can copy and paste the following code into a blank playground:

```javascript
const city = args[0];
const apiResponse = await Functions.makeHttpRequest({
 url: `https://wttr.in/${city}?format=3&m`,
 responseType: 'text'
});
if (apiResponse.error) {
 throw Error('Request failed');
}
const { data } = apiResponse;
return Functions.encodeString(data);

```

Copy the HTTP request [https://wttr.in/${city}?format=3\&m](https://wttr.in/$%7Bcity%7D?format=3\&m) and replace `city` with Sao-Paulo in a browser to see the expected result:

<div align="left"><figure><img src="/files/DFzCVZD8J2aifq34TZG2" alt=""><figcaption><p>The expected output</p></figcaption></figure></div>

Back in the playground, 1. make sure the “Argument” is `Sao-Paulo` then 2. click the “Run code” blue button at the bottom left and 3. the “Output” will be displayed:

<figure><img src="/files/RbrmyTLKQSZ78ePTA04s" alt=""><figcaption><p>You get the expected weather back!</p></figcaption></figure>

{% hint style="info" %}
Try your city or your next vacation spot!
{% endhint %}

Navigate back to your subscription on [Chainlink Functions](https://functions.chain.link/) and click the "Add consumer" button on the far right:

{% hint style="info" %}
You can have multiple consumer contracts in a single Chainlink Functions Subscription (up to 100)

[Chainlink Functions Service Limits](https://docs.chain.link/chainlink-functions/resources/service-limits)
{% endhint %}

<figure><img src="/files/5CXy6KrdxN7x05sCtdj0" alt=""><figcaption><p>Time to add a consumer</p></figcaption></figure>

Now 1. paste in your `WeatherFunctions.sol` deployed address and then 2. click the “Add consumer” blue button:

<figure><img src="/files/awvRkLJv4KKbQ1tuHo2g" alt=""><figcaption><p>Paste in your consumer address and add the consumer</p></figcaption></figure>

MetaMask will pop-up for you to confirm the transaction:

<figure><img src="/files/u0pKrodAuJCGRmevuyql" alt=""><figcaption><p>Confirm the transaction</p></figcaption></figure>

Once the transaction is confirmed, refresh the page and you will now see your new consumer:

<figure><img src="/files/Q6AKuynBsZsxrd5RxJ7Z" alt=""><figcaption><p>Successfully added another consumer to your subscription</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cll-devrel.gitbook.io/bootcamp-2024/9.-off-chain-data-with-chainlink-functions/city-weather-and-examples.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
