37```
38
39Refer to [Twitter's search operators](https://developer.twitter.com/en/docs/twitter-api/v1/rules-and-filtering/search-operators) to fine-tune your query.
40
41### 4. Test API call
42Set `isProd = false` in the code if you are testing, to ensure there are enough tweets to display. <br>
43Toggle it back to `true` when you're ready to run this cron job in production.
61
62### NOTE: Usage Limits
63This val uses the SocialData API for Twitter data:
64- **Proxies via Val Town's SocialDataProxy**: Limited to 100 calls/day for [**Val Town Pro users**](https://www.val.town/pricing).
65- **Need more calls?** Sign up for your own [SocialData API token](https://socialdata.tools) and configure the [`socialDataSearch`](https://www.val.town/v/stevekrouse/socialDataSearch) function.
19```
20
21You can use this library with https://www.val.town/v/maxm/transformEvalCode to return the last value without needing to export it. This is how the /eval api endpoint used to work and makes the library preform similarly to a repl.
22
23```ts
8import { Wide } from 'https://esm.town/v/maxm/wide';
9
10// Use your Val Town API Token to create a session
11const wide = new Wide(await ValSession.new(Deno.env.get("valtown")))
12
1import { ValSession } from "https://esm.town/v/maxm/valSession";
2// import type { TSearchFilter, WideApi } from "https://esm.town/v/maxm/wideApi";
3type WideApi = any;
4type TSearchFilter = any;
5import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
7
8const { htmlUrl } = extractValInfo(import.meta.url);
9const _client = hc<WideApi>("https://maxm-wideapi.web.val.run/");
10
11export class Wide {
14 constructor(sessionToken: string) {
15 // TODO: can we use a global client?
16 this.#client = hc<WideApi>("https://maxm-wideapi.web.val.run/");
17 this.#sessionToken = sessionToken;
18 }
75
76export default async function(req: Request): Promise<Response> {
77 // Use your Val Town API Token to create a session
78 const wide = new Wide(await ValSession.new(Deno.env.get("valtown")));
79 await wide.write([{
98 <script>hljs.highlightAll();</script>
99 <style>
100 @import url('https://fonts.googleapis.com/css2?family=Kumbh+Sans:wght@900&family=Roboto+Mono:wght@400;700&display=swap');
101
102 * {
196import { Wide } from 'https://esm.town/v/maxm/wide';
197
198// Use your Val Town API Token to create a session
199const wide = new Wide(await ValSession.new(Deno.env.get("valtown")))
200
4import { ValSession } from "https://esm.town/v/maxm/valSession";
5
6// Generate a token from your valtown api key.
7const token = await ValSession.newSession(Deno.env.get("valtown"));
8
101 <pre><code class="language-typescript">import { ValSession } from "${rawUrl}";
102
103// Generate a token from your valtown api key.
104const token = await ValSession.new(Deno.env.get("valtown"));
105
127});
128
129type valSessionApi = typeof routes;
130
131const client = hc<valSessionApi>(httpEndpoint);
132
133export class ValSession {
4import { ValSession } from "https://esm.town/v/maxm/valSession";
5
6// Generate a token from your valtown api key.
7const token = await ValSession.newSession(Deno.env.get("valtown"));
8
101 <pre><code class="language-typescript">import { ValSession } from "${rawUrl}";
102
103// Generate a token from your valtown api key.
104const token = await ValSession.new(Deno.env.get("valtown"));
105
127});
128
129type valSessionApi = typeof routes;
130
131const client = hc<valSessionApi>(httpEndpoint);
132
133export class ValSession {
97 const { access_token } = await tokenResponse.json();
98
99 const userResponse = await fetch("https://api.github.com/user", {
100 headers: {
101 "Authorization": `token ${access_token}`,
14and the `excludes` for what you don't want to get notified for.
15
16You can use [Twitter's search operators](https://developer.twitter.com/en/docs/twitter-api/v1/rules-and-filtering/search-operators) to customize your query, for some collection of keywords, filtering out others, and much more!
17
18## 2. Notification
22## Twitter Data & Limitations
23
24The Twitter API has become unusable. This val gets Twitter data via [SocialData](https://socialdata.tools),
25an affordable Twitter scraping API. In order to make this val easy for
26you to fork & use without signing up for another API, I am proxying
27SocialData via @stevekrouse/socialDataProxy. Val Town Pro users can call this proxy
28100 times per day, so be sure not to set this cron to run more than once every 15 min.
29
30If you want to run it more, get your own [SocialData](https://socialdata.tools)
31API token and pay for it directly.