gtm-tool-finder-api 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: fd7334df88ca9605c51d658692cb4bc4dc223f89db8d68cd926ded7c8bf136b8
4
+ data.tar.gz: ec3f9dfc99c33501ab5c117de98271b8ef92cc1232d768b07db0f07b52dfbb10
5
+ SHA512:
6
+ metadata.gz: 6c285c58f697f804a995ce2b3b727a9258e86681ab6915a9afdbec51464772ea3e552abd21755a2b8c113d68f73de6dc511f606c2acbaf22bcf63fa43d6a38c7
7
+ data.tar.gz: f5f804077f6ab53dc6cff88ae275a6adb38fa0e3286c2a2034696228985c9de4a76a7a95c12b03e0e00be0c8be9b71bc4408bfb0ab8d4824f432f461d3d48b32
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OneGTMLab
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.
22
+
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # gtm-tool-finder-ruby
2
+
3
+ A small Ruby client and command-line tool for the free, read-only
4
+ [GTM Tool Finder API](https://gtm-tool-finder-api.jaizendra.workers.dev), which serves the public
5
+ [OneGTMLab GTM tool directory](https://www.onegtmlab.dev/tool-directory): API reviews of sales and marketing tools,
6
+ head-to-head comparisons and plain-English glossary terms. No API key, no sign-up. Standard library only (`net/http`, `json`).
7
+
8
+ ## Use
9
+
10
+ ```ruby
11
+ require "gtm_tool_finder"
12
+
13
+ client = GtmToolFinder::Client.new
14
+
15
+ entries, total = client.search(q: "enrichment", kind: "tool", limit: 5)
16
+ entries.each { |e| puts "#{e.name} #{e.url}" }
17
+
18
+ client.get_entry("attio").description
19
+ client.categories.map { |c| [c["slug"], c["tool_count"]] }
20
+
21
+ # every comparison, following the API's offset pagination (100 per page)
22
+ client.each_entry(kind: "comparison") { |e| puts e.name }
23
+ ```
24
+
25
+ ## Command line
26
+
27
+ ```bash
28
+ bin/gtm-tool-finder apollo
29
+ bin/gtm-tool-finder --kind comparison --limit 5 clay
30
+ bin/gtm-tool-finder --categories
31
+ bin/gtm-tool-finder --get attio --json
32
+ ```
33
+
34
+ ## Test
35
+
36
+ ```bash
37
+ ruby test/test_client.rb
38
+ ```
39
+
40
+ The tests call the live API, so they need an internet connection.
41
+
42
+ ## API
43
+
44
+ `GET /tools?q=&kind=&category=&limit=&offset=` (`kind` is `tool`, `category`, `comparison` or `glossary`; `limit` 1 to 100),
45
+ `GET /tools/{id}`, `GET /categories`, `GET /openapi.json`.
46
+
47
+ Built by [OneGTMLab](https://www.onegtmlab.dev), a GTM engineering agency. MIT licensed.
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
5
+ require "optparse"
6
+ require "gtm_tool_finder"
7
+
8
+ opts = { limit: 10 }
9
+ parser = OptionParser.new do |o|
10
+ o.banner = "Usage: gtm-tool-finder [options] [words...]"
11
+ o.on("--kind KIND", GtmToolFinder::KINDS, "tool, category, comparison or glossary") { |v| opts[:kind] = v }
12
+ o.on("--category SLUG", "category slug, for example crm") { |v| opts[:category] = v }
13
+ o.on("--limit N", Integer, "results to show (1-100, default 10)") { |v| opts[:limit] = v }
14
+ o.on("--json", "print raw JSON") { opts[:json] = true }
15
+ o.on("--categories", "list the categories with tool counts") { opts[:categories] = true }
16
+ o.on("--get ID", "show one entry by id") { |v| opts[:get] = v }
17
+ end
18
+ parser.parse!
19
+ client = GtmToolFinder::Client.new
20
+
21
+ begin
22
+ if opts[:categories]
23
+ client.categories.each { |c| puts format("%-18s %3d %s", c["slug"], c["tool_count"], c["url"]) }
24
+ elsif opts[:get]
25
+ e = client.get_entry(opts[:get])
26
+ puts opts[:json] ? JSON.pretty_generate(e.to_h) : "#{e.name} [#{e.kind}]\n#{e.url}\n#{e.description}"
27
+ else
28
+ entries, total = client.search(q: ARGV.join(" ").strip, kind: opts[:kind], category: opts[:category], limit: opts[:limit])
29
+ if opts[:json]
30
+ puts JSON.pretty_generate(total: total, data: entries.map(&:to_h))
31
+ else
32
+ entries.each { |e| puts "#{e.name} [#{e.kind}]\n #{e.url}" }
33
+ puts "#{entries.size} of #{total} matches"
34
+ end
35
+ end
36
+ rescue GtmToolFinder::Error => e
37
+ warn "error: #{e.message}"
38
+ exit 1
39
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "net/http"
5
+ require "uri"
6
+
7
+ # Client for the free, read-only GTM Tool Finder API that serves the public
8
+ # OneGTMLab GTM tool directory (https://www.onegtmlab.dev/tool-directory).
9
+ module GtmToolFinder
10
+ BASE_URL = "https://gtm-tool-finder-api.jaizendra.workers.dev"
11
+ KINDS = %w[tool category comparison glossary].freeze
12
+
13
+ class Error < StandardError; end
14
+ class NotFound < Error; end
15
+
16
+ # One directory entry: id, name, kind, category, url, description.
17
+ Entry = Struct.new(:id, :name, :kind, :category, :url, :description, keyword_init: true)
18
+
19
+ class Client
20
+ def initialize(base_url: BASE_URL, open_timeout: 10, read_timeout: 20)
21
+ @base = base_url.chomp("/")
22
+ @open_timeout = open_timeout
23
+ @read_timeout = read_timeout
24
+ end
25
+
26
+ # Search the directory. All words in +q+ must appear in the name or description.
27
+ # Returns [entries, total].
28
+ def search(q: nil, kind: nil, category: nil, limit: 20, offset: 0)
29
+ raise ArgumentError, "kind must be one of #{KINDS.join(', ')}" if kind && !KINDS.include?(kind.to_s)
30
+ raise ArgumentError, "limit must be 1..100" unless (1..100).cover?(limit)
31
+
32
+ params = { q: q, kind: kind, category: category, limit: limit, offset: offset }.compact
33
+ body = get("/tools", params)
34
+ [body.fetch("data").map { |h| to_entry(h) }, body.fetch("total")]
35
+ end
36
+
37
+ # One entry by id, for example "attio". Raises NotFound for an unknown id.
38
+ def get_entry(id)
39
+ to_entry(get("/tools/#{URI.encode_www_form_component(id)}"))
40
+ end
41
+
42
+ # The tool categories with tool counts: array of hashes (id, slug, name, url, description, tool_count).
43
+ def categories
44
+ get("/categories").fetch("data")
45
+ end
46
+
47
+ # Every entry, following offset pagination 100 at a time.
48
+ def each_entry(**filters)
49
+ return enum_for(:each_entry, **filters) unless block_given?
50
+
51
+ offset = 0
52
+ loop do
53
+ page, total = search(**filters, limit: 100, offset: offset)
54
+ page.each { |e| yield e }
55
+ offset += page.size
56
+ break if page.empty? || offset >= total
57
+ end
58
+ end
59
+
60
+ private
61
+
62
+ def get(path, params = {})
63
+ uri = URI(@base + path)
64
+ uri.query = URI.encode_www_form(params) unless params.empty?
65
+ http = Net::HTTP.new(uri.host, uri.port)
66
+ http.use_ssl = uri.scheme == "https"
67
+ http.open_timeout = @open_timeout
68
+ http.read_timeout = @read_timeout
69
+ res = http.request(Net::HTTP::Get.new(uri, "Accept" => "application/json", "User-Agent" => "gtm-tool-finder-ruby/0.1.0"))
70
+ case res
71
+ when Net::HTTPSuccess then JSON.parse(res.body)
72
+ when Net::HTTPNotFound then raise NotFound, "not found: #{path}"
73
+ else raise Error, "HTTP #{res.code} for #{path}"
74
+ end
75
+ end
76
+
77
+ def to_entry(hash)
78
+ Entry.new(**hash.slice("id", "name", "kind", "category", "url", "description").transform_keys(&:to_sym))
79
+ end
80
+ end
81
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gtm-tool-finder-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - OneGTMLab
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ executables:
13
+ - gtm-tool-finder
14
+ extensions: []
15
+ extra_rdoc_files: []
16
+ files:
17
+ - LICENSE
18
+ - README.md
19
+ - bin/gtm-tool-finder
20
+ - lib/gtm_tool_finder.rb
21
+ homepage: "https://www.onegtmlab.dev/tool-directory"
22
+ licenses:
23
+ - MIT
24
+ metadata:
25
+ source_code_uri: "https://github.com/jaizendra-netizen/gtm-tool-finder-ruby"
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ -
32
+ - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "2.7"
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ -
38
+ - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: "0"
41
+ requirements: []
42
+ rubygems_version: 4.1.0
43
+ specification_version: 4
44
+ summary: Ruby client for the free GTM Tool Finder API (OneGTMLab GTM tool directory)
45
+ test_files: []