readwhitepaper 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7bfa6b799eaef4e5a86a4ca4525f37b815cc9c28fd1542f32b64cb762b254a4a
4
+ data.tar.gz: 4ba87c616663bb14273c7fc4ca354004334884665fcb5c8c74b611c8fd79958e
5
+ SHA512:
6
+ metadata.gz: 46c032496af8c6a4f4a34c1a30e1788e08b5357f7ea336f2620558ce275b42e55e3be0914989b3f90f454a83e7bbc3991ccfaaaca1e746ea96674f15bdfc91a8
7
+ data.tar.gz: b2d1c580aa7d5202872c17cf54b25cb09f0811ca386dac3f479a31f4127a989bdcc21204e5945ece0311a258da1852bfe54a58e6199a0b2bdfe857f60beeb40a
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dobestan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # readwhitepaper
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/readwhitepaper.svg)](https://rubygems.org/gems/readwhitepaper)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+ [![Zero Dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)](https://rubygems.org/gems/readwhitepaper)
6
+
7
+ Ruby client for the [ReadWhitepaper](https://readwhitepaper.com) API — a blockchain whitepaper database hosting 30 cryptocurrency whitepapers with section-level content, 163 glossary terms, full-text search, and 3,458 translations across 15 languages. Zero dependencies, uses only `net/http`.
8
+
9
+ > **Explore the whitepapers at [readwhitepaper.com](https://readwhitepaper.com)** — [Bitcoin Whitepaper](https://readwhitepaper.com/bitcoin/), [Ethereum Whitepaper](https://readwhitepaper.com/ethereum/), [API Docs](https://readwhitepaper.com/developers/)
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ gem install readwhitepaper
15
+ ```
16
+
17
+ Or add to your Gemfile:
18
+
19
+ ```ruby
20
+ gem "readwhitepaper"
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ```ruby
26
+ require "readwhitepaper"
27
+
28
+ # Initialize the client — no API key needed
29
+ client = ReadWhitepaper::Client.new
30
+
31
+ # List all 30 cryptocurrency whitepapers
32
+ whitepapers = client.list_whitepapers
33
+ whitepapers["results"].each do |wp|
34
+ puts "#{wp['crypto']['ticker']} — #{wp['authors'].first} (#{wp['year']})"
35
+ # BTC — Satoshi Nakamoto (2008)
36
+ # ETH — Vitalik Buterin (2013)
37
+ end
38
+
39
+ # Read Bitcoin's whitepaper section by section
40
+ bitcoin = client.get_whitepaper("bitcoin")
41
+ bitcoin["sections"].each do |section|
42
+ puts "§#{section['section_number']}: #{section['heading_text']}"
43
+ end
44
+
45
+ # Search across all whitepapers
46
+ results = client.search("proof of work")
47
+ results.each do |r|
48
+ puts "#{r['slug']} — #{r['heading']}: #{r['snippet']}"
49
+ end
50
+
51
+ # Get the blockchain glossary
52
+ glossary = client.list_glossary(limit: 5)
53
+ glossary["results"].each do |term|
54
+ puts "#{term['term']} [#{term['category']}] — appears #{term['occurrence_count']}x"
55
+ end
56
+ ```
57
+
58
+ ## What You'll Find on ReadWhitepaper
59
+
60
+ ReadWhitepaper hosts the foundational documents of 30 major cryptocurrencies. A cryptocurrency whitepaper is the primary technical document describing a blockchain protocol's design, consensus mechanism, and economic model. The tradition began with Satoshi Nakamoto's 2008 Bitcoin whitepaper.
61
+
62
+ | Rank | Ticker | Author(s) | Year | Sections |
63
+ |------|--------|-----------|------|----------|
64
+ | 1 | BTC | Satoshi Nakamoto | 2008 | 14 |
65
+ | 2 | ETH | Vitalik Buterin | 2013 | 23 |
66
+ | 3 | USDT | J.R. Willett | 2016 | 10 |
67
+ | 4 | XRP | D. Schwartz, N. Youngs, A. Britto | 2014 | 11 |
68
+ | 5 | SOL | Anatoly Yakovenko | 2017 | 12 |
69
+
70
+ 163 blockchain glossary terms across 12 categories, 15-language translations with 3,458 individual translations, and a whitepaper relationship graph.
71
+
72
+ ## API Methods
73
+
74
+ | Method | Description |
75
+ |--------|-------------|
76
+ | `list_whitepapers(limit:, page:, language:)` | List all 30 whitepapers |
77
+ | `get_whitepaper(slug, language:)` | Get whitepaper detail with sections |
78
+ | `get_sections(slug, language:)` | Get sections only |
79
+ | `get_toc(slug, language:)` | Get table of contents |
80
+ | `get_coverage(slug)` | Get translation coverage |
81
+ | `list_glossary(limit:, page:, language:)` | List 163 glossary terms |
82
+ | `get_glossary_term(slug, language:)` | Get term detail |
83
+ | `search(query, slug:, language:)` | Full-text search |
84
+ | `get_stats` | Platform statistics |
85
+ | `get_languages` | Supported languages |
86
+ | `get_graph` | Relationship graph |
87
+
88
+ ## Learn More About Blockchain Whitepapers
89
+
90
+ - **Read**: [Bitcoin Whitepaper](https://readwhitepaper.com/bitcoin/) . [Ethereum Whitepaper](https://readwhitepaper.com/ethereum/) . [All Whitepapers](https://readwhitepaper.com/)
91
+ - **Explore**: [Blockchain Glossary](https://readwhitepaper.com/glossary/) . [Whitepaper Graph](https://readwhitepaper.com/graph/)
92
+ - **API**: [REST API Docs](https://readwhitepaper.com/developers/)
93
+
94
+ ## Also Available
95
+
96
+ | Platform | Package | Install |
97
+ |----------|---------|---------|
98
+ | **PyPI** | [readwhitepaper](https://pypi.org/project/readwhitepaper/) | `pip install readwhitepaper` |
99
+ | **npm** | [readwhitepaper](https://www.npmjs.com/package/readwhitepaper) | `npm install readwhitepaper` |
100
+ | **Go** | [readwhitepaper-go](https://github.com/dobestan/readwhitepaper-go) | `go get github.com/dobestan/readwhitepaper-go` |
101
+ | **Rust** | [readwhitepaper](https://crates.io/crates/readwhitepaper) | `cargo add readwhitepaper` |
102
+
103
+ ## License
104
+
105
+ MIT
@@ -0,0 +1,163 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "net/http"
5
+ require "uri"
6
+
7
+ module ReadWhitepaper
8
+ # Client for the ReadWhitepaper blockchain whitepaper API.
9
+ #
10
+ # Provides access to 30 cryptocurrency whitepapers, 163 glossary terms,
11
+ # full-text search, and 15-language translations. Zero dependencies.
12
+ #
13
+ # @example
14
+ # client = ReadWhitepaper::Client.new
15
+ # whitepapers = client.list_whitepapers
16
+ # bitcoin = client.get_whitepaper("bitcoin")
17
+ # results = client.search("proof of work")
18
+ class Client
19
+ DEFAULT_BASE_URL = "https://readwhitepaper.com/api"
20
+ DEFAULT_TIMEOUT = 30
21
+
22
+ # @param base_url [String] API base URL
23
+ # @param language [String] Default language code
24
+ # @param timeout [Integer] Request timeout in seconds
25
+ def initialize(base_url: DEFAULT_BASE_URL, language: "en", timeout: DEFAULT_TIMEOUT)
26
+ @base_url = base_url.chomp("/")
27
+ @language = language
28
+ @timeout = timeout
29
+ end
30
+
31
+ # ── Whitepapers ──────────────────────────────────────────
32
+
33
+ # List all whitepapers with optional pagination.
34
+ # @param limit [Integer, nil] Number of results per page
35
+ # @param page [Integer, nil] Page number
36
+ # @param language [String, nil] Language code
37
+ # @return [Hash] Paginated response with :count, :next, :previous, :results
38
+ def list_whitepapers(limit: nil, page: nil, language: nil)
39
+ params = { language: language || @language }
40
+ params[:limit] = limit if limit
41
+ params[:page] = page if page
42
+ request("/whitepapers/", params)
43
+ end
44
+
45
+ # Get full whitepaper detail with all sections.
46
+ # @param slug [String] Whitepaper slug (e.g. "bitcoin", "ethereum")
47
+ # @param language [String, nil] Language code
48
+ # @return [Hash] Whitepaper detail with sections
49
+ def get_whitepaper(slug, language: nil)
50
+ request("/whitepapers/#{slug}/", { language: language || @language })
51
+ end
52
+
53
+ # Get whitepaper sections.
54
+ # @param slug [String] Whitepaper slug
55
+ # @param language [String, nil] Language code
56
+ # @return [Array<Hash>] List of sections
57
+ def get_sections(slug, language: nil)
58
+ request("/whitepapers/#{slug}/sections/", { language: language || @language })
59
+ end
60
+
61
+ # Get table of contents for a whitepaper.
62
+ # @param slug [String] Whitepaper slug
63
+ # @param language [String, nil] Language code
64
+ # @return [Array<Hash>] TOC entries
65
+ def get_toc(slug, language: nil)
66
+ data = request("/whitepapers/#{slug}/toc/", { language: language || @language })
67
+ data["toc"]
68
+ end
69
+
70
+ # Get translation coverage for a whitepaper.
71
+ # @param slug [String] Whitepaper slug
72
+ # @return [Hash] Coverage data with per-language completion
73
+ def get_coverage(slug)
74
+ request("/whitepapers/#{slug}/coverage/")
75
+ end
76
+
77
+ # ── Glossary ─────────────────────────────────────────────
78
+
79
+ # List blockchain glossary terms with pagination.
80
+ # @param limit [Integer, nil] Number of results per page
81
+ # @param page [Integer, nil] Page number
82
+ # @param language [String, nil] Language code
83
+ # @return [Hash] Paginated response
84
+ def list_glossary(limit: nil, page: nil, language: nil)
85
+ params = { language: language || @language }
86
+ params[:limit] = limit if limit
87
+ params[:page] = page if page
88
+ request("/glossary/", params)
89
+ end
90
+
91
+ # Get a single glossary term by slug.
92
+ # @param slug [String] Term slug (e.g. "blockchain", "consensus")
93
+ # @param language [String, nil] Language code
94
+ # @return [Hash] Glossary term with definition
95
+ def get_glossary_term(slug, language: nil)
96
+ request("/glossary/#{slug}/", { language: language || @language })
97
+ end
98
+
99
+ # ── Search ───────────────────────────────────────────────
100
+
101
+ # Full-text search across all whitepapers.
102
+ # @param query [String] Search query
103
+ # @param slug [String, nil] Limit to specific whitepaper
104
+ # @param language [String, nil] Language code
105
+ # @return [Array<Hash>] Search results with snippets
106
+ def search(query, slug: nil, language: nil)
107
+ params = { q: query, language: language || @language }
108
+ params[:slug] = slug if slug
109
+ data = request("/search/", params)
110
+ data["results"]
111
+ end
112
+
113
+ # ── Stats / Languages / Graph ────────────────────────────
114
+
115
+ # Get platform statistics.
116
+ # @return [Hash] Stats including counts and per-whitepaper data
117
+ def get_stats
118
+ request("/stats/")
119
+ end
120
+
121
+ # Get all supported languages.
122
+ # @return [Array<Hash>] Languages with code, name, direction
123
+ def get_languages
124
+ data = request("/languages/")
125
+ data.is_a?(Array) ? data : data["results"]
126
+ end
127
+
128
+ # Get the whitepaper relationship graph.
129
+ # @return [Hash] Graph with :nodes and :edges
130
+ def get_graph
131
+ request("/graph/")
132
+ end
133
+
134
+ private
135
+
136
+ def request(path, params = {})
137
+ uri = URI("#{@base_url}#{path}")
138
+ filtered = params.compact
139
+ uri.query = URI.encode_www_form(filtered) unless filtered.empty?
140
+
141
+ http = Net::HTTP.new(uri.host, uri.port)
142
+ http.use_ssl = uri.scheme == "https"
143
+ http.open_timeout = @timeout
144
+ http.read_timeout = @timeout
145
+
146
+ req = Net::HTTP::Get.new(uri)
147
+ req["Accept"] = "application/json"
148
+ req["User-Agent"] = "readwhitepaper-rb/#{VERSION}"
149
+
150
+ response = http.request(req)
151
+
152
+ unless response.is_a?(Net::HTTPSuccess)
153
+ body = response.body.to_s[0, 200]
154
+ raise APIError.new(
155
+ "HTTP #{response.code}: #{body}",
156
+ status_code: response.code.to_i
157
+ )
158
+ end
159
+
160
+ JSON.parse(response.body)
161
+ end
162
+ end
163
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # ReadWhitepaper — Ruby client for the blockchain whitepaper database API.
4
+ #
5
+ # 30 cryptocurrency whitepapers, 163 glossary terms,
6
+ # 3,458 translations across 15 languages.
7
+ #
8
+ # @example
9
+ # client = ReadWhitepaper::Client.new
10
+ # whitepapers = client.list_whitepapers
11
+ # bitcoin = client.get_whitepaper("bitcoin")
12
+
13
+ require_relative "readwhitepaper/client"
14
+
15
+ module ReadWhitepaper
16
+ VERSION = "0.1.0"
17
+
18
+ # Base error class for ReadWhitepaper API errors.
19
+ class Error < StandardError; end
20
+
21
+ # Raised when the API returns an error status code.
22
+ class APIError < Error
23
+ attr_reader :status_code
24
+
25
+ def initialize(message, status_code: nil)
26
+ @status_code = status_code
27
+ super(message)
28
+ end
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: readwhitepaper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - dobestan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-03-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby client for the ReadWhitepaper API — 30 cryptocurrency whitepapers
14
+ with section-level content, 163 glossary terms, full-text search, and 3,458 translations
15
+ across 15 languages. Zero dependencies.
16
+ email:
17
+ - dobestan@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - LICENSE
23
+ - README.md
24
+ - lib/readwhitepaper.rb
25
+ - lib/readwhitepaper/client.rb
26
+ homepage: https://readwhitepaper.com
27
+ licenses:
28
+ - MIT
29
+ metadata:
30
+ homepage_uri: https://readwhitepaper.com
31
+ source_code_uri: https://github.com/dobestan/readwhitepaper-rb
32
+ documentation_uri: https://readwhitepaper.com/developers/
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 3.0.0
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubygems_version: 3.0.3.1
49
+ signing_key:
50
+ specification_version: 4
51
+ summary: Ruby client for ReadWhitepaper — blockchain whitepaper database
52
+ test_files: []