Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gnuns/allorigins
:alien: Pull content from any page as JSON via API
https://github.com/gnuns/allorigins
api cors gzip javascript js json node-js nodejs request
Last synced: 9 days ago
JSON representation
:alien: Pull content from any page as JSON via API
- Host: GitHub
- URL: https://github.com/gnuns/allorigins
- Owner: gnuns
- License: mit
- Created: 2016-02-14T15:38:55.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2023-02-26T13:40:32.000Z (almost 2 years ago)
- Last Synced: 2025-02-05T07:05:15.944Z (16 days ago)
- Topics: api, cors, gzip, javascript, js, json, node-js, nodejs, request
- Language: JavaScript
- Homepage: https://allorigins.win/
- Size: 2.61 MB
- Stars: 785
- Watchers: 17
- Forks: 155
- Open Issues: 35
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
All Origins
=======
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fgnuns%2FAllOrigins?ref=badge_shield)
[](https://app.travis-ci.com/github/gnuns/allOrigins)
[](https://www.paypal.com/donate?hosted_button_id=7S3KJ8CA43DX6)Pull contents from any page via API (as JSON/P or raw) and avoid [Same-origin policy](https://en.wikipedia.org/wiki/Same-origin_policy) problems.
----
A free and open source javascript clone of [AnyOrigin](https://web.archive.org/web/20180807170914/http://anyorigin.com/), inspired by [Whatever Origin](http://WhateverOrigin.org), but with support to gzipped pages.
### Examples
To `fetch` data from http://wikipedia.org:
```js
fetch(`https://api.allorigins.win/get?url=${encodeURIComponent('https://wikipedia.org')}`)
.then(response => {
if (response.ok) return response.json()
throw new Error('Network response was not ok.')
})
.then(data => console.log(data.contents));
```Or with jQuery
```js
$.getJSON('https://api.allorigins.win/get?url=' + encodeURIComponent('https://wikipedia.org'), function (data) {
alert(data.contents);
});
```
### Options###### charset
**Description:** Set the response character encoding (charset) \
**Example:** `https://api.allorigins.win/get?charset=ISO-8859-1&url=https://pt.wikipedia.org/`###### raw
**Description:** Get the raw contents ([CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)) \
**Example:** `https://api.allorigins.win/raw?url=https://example.org/`###### callback
**Description:** Get a [JSONP](https://www.w3schools.com/js/js_json_jsonp.asp) response \
**Example:** `https://api.allorigins.win/get?callback=myFunc&url=https://example.org/`### On your own server
```sh# Clone the repo
git clone https://github.com/gnuns/AllOrigins# Install dependencies
cd AllOrigins
npm install# Fire it up!
npm start # the default port is 1458
```## License
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fgnuns%2FAllOrigins?ref=badge_large)