US Congress Stock Trading API examples & templates
Use these vals as a playground to view and fork US Congress Stock Trading API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
stevekrouse
getDayName
Script
Get the day of week name JavaScript's Date.prototype.getDay() returns a number that represents the day of the week, 0 for Sunday, 1 for Monday, etc. This function returns the name of the week, ie "Sunday" , "Monday" , etc. The function optionally inputs a Date object, but will default to the current time if none is provided.
0
stevekrouse
key_safe_link
HTTP
One-click environment variable Copying and pasting secret API keys into your Val Town Environment Variables is annoying and error prone. Wouldn't it be nice if you could add an environment variable in one click? What could such a protocol look like for third-party API company to be able to safely pass their customer's API keys to their customer's Val Town account. A naive approach to this would be a link that looks like this: <a href="https://www.val.town/settings/environment-variables?name=OpenAI&value=sk-123...">
Add OpenAI key to Val Town
</a> However it isn't safe to put API key values in URLs like that, but it would be great if we could still put it in the URL so it can act like a simple link. We need to encrypt the API key in such a way that nobody can read it except for the Val Town app. Val Town could provide a public key for API providers to encrypt their tokens with. We could add an extra layer of security by including the timestamp in the request as well as the Val Town username that the token is intended for. All that data should be included in the encrypted package. We can also ensure that each such link is used exactly once. This scheme does feel a bit ad hoc though, so it'd be nice if there existed another protocol for doing this that we could use.
0
andreterron
form_handler
HTTP
Receive form responses Live demo: https://andreterron-form_demo.web.val.run/ Create a form that posts to your val: <form action="https://andreterron-form_handler.web.val.run" method="post">
<label for="username">Val Town username:</label>
<input name="username" type="text">
<button type="submit">Submit</button>
</form> And get your results stored as an array: // set by andreterron.form_handler at 2023-08-10T21:04:43.364Z
let formResponses = [{
"username": "andreterron",
},
{
"username": "stevekrouse",
}]; Usage Fork this val and click the 🔒 to set it as "Unlisted" Open the val menu → Endpoints → "Copy web endpoint" Use that url as the action attribute of your form Check out the example val: https://www.val.town/v/andreterron.form_demo Storage of form submissions This val saves to another val ( @me.formResponse ), which has a 100kb limitation (250kb for pro users), if you want to store them in a more scalable solution, check out our guides
1
rozek
GDI_MarkDown_Examples
Script
MarkDown Rendering Examples Which MarkDown primitives are
supported and how do they look like? (edit this ReadMe in order to find out how it was written) Important: no, Val Town does not support "GitHub-flavoured" Markdown (GfM)! Level 1 Heading (followed by some plain text) Level 2 Heading (followed by some plain text) Level 3 Heading (followed by some plain text) Level 4 Heading (followed by some plain text) Level 5 Heading (followed by some plain text) Level 6 Heading (followed by some plain text) Nota bene: while heading levels 5 and 6 look useless, they still have an
implied anchor which may be used in links to explicitly navigate there Paragraphs Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Text Styling (and Links) This text is italicised , and this one set in bold , in bold italics
or ~~striked-through~~, but you may also superset or
subset text. Links Your text may also contain links , even
relative ones which navigate to other locations
within the same text. Unordered Lists list item 1 list item 2 inner list item 2.1 inner list item 2.2 inner list item 2.3 list item 3 inner list item 3.1 inner list item 3.2 inner list item 3.3 list item 4 Ordered Lists list item 1 list item 2 inner list item 2.1 inner list item 2.2 inner list item 2.3 list item 3 inner list item 3.1 inner list item 3.2 inner list item 3.3 list item 4 Nota bene: in order to nest lists, inner list items have to be indentend by at least 4 spaces! ToDo Lists [x] already done [ ] still pending [x] but partially done Text Indentation Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. Nota bene: text indentation does not seem to work - it looks a bit like a code paragraph Quotations Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. Code You may render code inline within your text or as a separate paragraph: console.log('Hello, World!') Important: Keep in mind that you can tag code paragraphs with a
(programming) language - not only for syntax highlighting, but also in order
to avoid the nasty look shown in the "Text Indentation" section. Images Horizontal Lines (some text above...) (...and some text below the horizontal line) Footnotes and their Contents Your text may contain footnotes[^1]. And, while you may define the contents
of your footnote anywhere in the text, it is rendered at the end only - thus,
make sure, that you add a "dangling" heading! [^1]: this is just an example for a foot note Raw HTML Markup Important: You may even insert a subset of HTML into your Markdown code Unfortunately, however, e.g., iframes are not supported. References
0