Skip to main content

Sherlock Domains Agentic SDK for python

Project description

Sherlock Domains Python SDK

Installation

Install latest from the GitHub repository:

$ pip install git+https://github.com/Fewsats/sherlock-python.git
$ pip install sherlock-domains

How to use

Create a Sherlock instance with a private key for the agent to use. If no key is provided, a new one will be generated and saved to the default config file.

s = Sherlock()
s
Sherlock(pubkey=90ba884688884277e49080712f386eebc88806efa8345ca937f75fe80950156d)

You can search for a domain and request to purchase it. Purchasing a domain requires contact information as mandated by ICANN.

sr = s.search("trakwiska.com")
sr
{'id': '7f53df53-7090-4c3f-a41a-55bd345a8f95',
 'created_at': '2025-01-10T08:22:09.172Z',
 'available': [{'name': 'trakwiska.com',
   'tld': 'com',
   'tags': [],
   'price': 1105,
   'currency': 'USD',
   'available': True},
  {'name': 'trakwiska.net',
   'tld': 'net',
   'tags': [],
   'price': 1185,
   'currency': 'USD',
   'available': True},
  {'name': 'trakwiska.org',
   'tld': 'org',
   'tags': [],
   'price': 939,
   'currency': 'USD',
   'available': True},
  {'name': 'trakwiska.store',
   'tld': 'store',
   'tags': [],
   'price': 488,
   'currency': 'USD',
   'available': True},
  {'name': 'trakwiska.app',
   'tld': 'app',
   'tags': [],
   'price': 1689,
   'currency': 'USD',
   'available': True},
  {'name': 'trakwiska.dev',
   'tld': 'dev',
   'tags': [],
   'price': 1489,
   'currency': 'USD',
   'available': True},
  {'name': 'trakwiska.io',
   'tld': 'io',
   'tags': [],
   'price': 3489,
   'currency': 'USD',
   'available': True},
  {'name': 'trakwiska.xyz',
   'tld': 'xyz',
   'tags': [],
   'price': 269,
   'currency': 'USD',
   'available': True},
  {'name': 'trakwiska.tech',
   'tld': 'tech',
   'tags': [],
   'price': 819,
   'currency': 'USD',
   'available': True},
  {'name': 'trakwiska.info',
   'tld': 'info',
   'tags': [],
   'price': 429,
   'currency': 'USD',
   'available': True},
  {'name': 'trakwiska.me',
   'tld': 'me',
   'tags': [],
   'price': 488,
   'currency': 'USD',
   'available': True},
  {'name': 'trakwiska.ai',
   'tld': 'ai',
   'tags': [],
   'price': 7489,
   'currency': 'USD',
   'available': True}],
 'unavailable': []}

Contact information is needed for registering a new domain with the ICANN.

c = Contact(**{
    "first_name": "Test",
    "last_name": "User",
    "email": "test@example.com",
    "address": "123 Test St",
    "city": "Test City",
    "state": "CA",
    "country": "US",
    "postal_code": "12345",
})

s.set_contact_information(
    cfn=c.first_name,
    cln=c.last_name,
    cem=c.email,
    cadd=c.address,
    cct=c.city,
    cst=c.state,
    cpc=c.postal_code,
    ccn=c.country
)
{'message': 'Contact information updated successfully'}

Finalizing a pruchase involves a payment. Sherlock Domains currently supports two payment methods: Credit Card (credit_card) and the Lightning Netowrk (lightning). By default the credit card method is used. The method will then return a checkout URL that can be used to complete the payment. In the case of lightning the response will contain a lightning invoice.

s.purchase_domain(sr['id'], "trakwiska.com")
{'payment_method': {'checkout_url': 'https://checkout.stripe.com/c/pay/cs_live_a1GGYxOdMQW3ML018fHyqpP0QdFPoK5yuy3KgredBSwPk93idtlY5vTqQS#fidkdWxOYHwnPyd1blppbHNgWjA0S3VzXDdBbTFNVlJzfDVRQVQ2dVdBTnJTSH1QMGs2dHRsanJMbkY0PTxKbUtRaWowT2NwMGM8RlVBbGRqSWo3UFYwcVdqR3F9N2BtM2ZTPXc1Z3dQXGc2NTVPYVVSQkM8bycpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl',
  'lightning_invoice': None},
 'expires_at': '2025-01-10T08:52:10.708Z'}

You can now use the checkout URL to complete the purchase and the domain will be registered to your agent.

You can view the domains you own with:

s.domains()
[{'id': 'd9b2cc30-c15d-44b9-9d39-5d33da504484',
  'domain_name': 'h402.org',
  'created_at': '2024-12-28T18:58:49.899Z',
  'expires_at': '2024-12-31T18:58:42Z',
  'auto_renew': False,
  'locked': True,
  'private': True,
  'nameservers': [],
  'status': 'active'}]

Below is a list of all the tools that the client offers to manage the domains and purchases.

s.as_tools().map(lambda t: t.__name__)
(#10) ['_me','_set_contact_information','_get_contact_information','_search','_purchase_domain','_domains','_dns_records','_create_dns_record','_update_dns_record','_delete_dns_record']

AI agents

We will show how to enable your AI assistant to handle payments using Claudette, Answer.ai convenient wrapper for Claude. You’ll need to export your ANTHROPIC_API_KEY.

from claudette import Chat, models
model = models[1]; model
'claude-3-5-sonnet-20240620'

Create a Sherlock instance with a public & private key for the agent to use.

Sherlock supports returning all the tools with s.as_tools().

In order to request a purchase, we need to provide a contact information. You can either do so during the class initialization or manually. Then we just pass the extra tool.

sp = 'You are a helpful assistant that has access to a domain purchase API.'
chat = Chat(model, sp=sp, tools=s.as_tools())

pr = f"Search if domain 'the-favourite-game.com' is available? If it is request a purchase and process the payment using credit card method."
r = chat.toolloop(pr, trace_func=print)
r
    Message(id='msg_01RGrzPSYkPGoof9qAgt3sVB', content=[TextBlock(text="Certainly! I'll search for the domain 'the-favourite-game.com' and if it's available, I'll proceed with the purchase request using the credit card payment method. Let's start with the search.", type='text'), ToolUseBlock(id='toolu_01HY1brwGzrYiCEK2xWrFhBF', input={'q': 'the-favourite-game.com'}, name='_search', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=In: 3003; Out: 104; Cache create: 0; Cache read: 0; Total: 3107)
    Message(id='msg_01VqNeG8C9eG4prq6G7ZcLun', content=[TextBlock(text="Great news! The domain 'the-favourite-game.com' is available for purchase. The search results show that it's priced at 1105 cents (USD), which is equivalent to $11.05.\n\nNow that we've confirmed its availability, let's proceed with the purchase request using the credit card payment method. However, before we can do that, we need to make sure that the contact information is set up for the domain registration. Let's check the current contact information:", type='text'), ToolUseBlock(id='toolu_01NUMoFmu9MuSJSuf2kC77zE', input={}, name='_get_contact_information', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=In: 3766; Out: 143; Cache create: 0; Cache read: 0; Total: 3909)
    Message(id='msg_01B54nf4ERFjzeK22SnMSZCo', content=[TextBlock(text='It looks like the contact information is already set up. Now we can proceed with the purchase request:', type='text'), ToolUseBlock(id='toolu_017hhGaifyqSfcWVViGrwpPu', input={'sid': '6a511874-ccb6-47c7-a05c-9636a55b1c1a', 'domain': 'the-favourite-game.com', 'payment_method': 'credit_card'}, name='_purchase_domain', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=In: 3996; Out: 144; Cache create: 0; Cache read: 0; Total: 4140)
    Message(id='msg_01KDKMFFZ5ELDToH3wMbhjps', content=[TextBlock(text="Excellent! The purchase request for 'the-favourite-game.com' has been processed successfully. Here's what you need to know:\n\n1. The domain 'the-favourite-game.com' is available and has been reserved for your purchase.\n2. The payment method selected is credit card, as requested.\n3. To complete the purchase, you need to use the provided checkout URL:\n   https://checkout.stripe.com/c/pay/cs_live_a1w7dHEJsQeXWtL48V27bJqUA9isb3HWCa43srMdsTJKDZg1ZDzqL6FsZc#fidkdWxOYHwnPyd1blppbHNgWjA0S3VzXDdBbTFNVlJzfDVRQVQ2dVdBTnJTSH1QMGs2dHRsanJMbkY0PTxKbUtRaWowT2NwMGM8RlVBbGRqSWo3UFYwcVdqR3F9N2BtM2ZTPXc1Z3dQXGc2NTVPYVVSQkM8bycpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl\n\n4. The payment reservation expires at: 2025-01-10T08:52:20.253Z (about 30 minutes from now)\n\nTo complete the purchase, please follow these steps:\n1. Click on the checkout URL provided above.\n2. You will be redirected to a secure Stripe payment page.\n3. Enter your credit card details and complete the payment process.\n4. Once the payment is successful, the domain will be registered to you.\n\nMake sure to complete the payment before the expiration time to secure your domain. If you have any issues with the payment process or need any further assistance, please let me know.", type='text')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='end_turn', stop_sequence=None, type='message', usage=In: 4495; Out: 532; Cache create: 0; Cache read: 0; Total: 5027)

Excellent! The purchase request for ‘the-favourite-game.com’ has been
processed successfully. Here’s what you need to know:

1.  The domain ‘the-favourite-game.com’ is available and has been
    reserved for your purchase.

2.  The payment method selected is credit card, as requested.

3.  To complete the purchase, you need to use the provided checkout URL:
    https://checkout.stripe.com/c/pay/cs_live_a1w7dHEJsQeXWtL48V27bJqUA9isb3HWCa43srMdsTJKDZg1ZDzqL6FsZc#fidkdWxOYHwnPyd1blppbHNgWjA0S3VzXDdBbTFNVlJzfDVRQVQ2dVdBTnJTSH1QMGs2dHRsanJMbkY0PTxKbUtRaWowT2NwMGM8RlVBbGRqSWo3UFYwcVdqR3F9N2BtM2ZTPXc1Z3dQXGc2NTVPYVVSQkM8bycpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl

4.  The payment reservation expires at: 2025-01-10T08:52:20.253Z (about
    30 minutes from now)

To complete the purchase, please follow these steps: 1. Click on the
checkout URL provided above. 2. You will be redirected to a secure
Stripe payment page. 3. Enter your credit card details and complete the
payment process. 4. Once the payment is successful, the domain will be
registered to you.

Make sure to complete the payment before the expiration time to secure
your domain. If you have any issues with the payment process or need any
further assistance, please let me know.
<details>

- id: `msg_01KDKMFFZ5ELDToH3wMbhjps`
- content:
  `[{'text': "Excellent! The purchase request for 'the-favourite-game.com' has been processed successfully. Here's what you need to know:\n\n1. The domain 'the-favourite-game.com' is available and has been reserved for your purchase.\n2. The payment method selected is credit card, as requested.\n3. To complete the purchase, you need to use the provided checkout URL:\n   https://checkout.stripe.com/c/pay/cs_live_a1w7dHEJsQeXWtL48V27bJqUA9isb3HWCa43srMdsTJKDZg1ZDzqL6FsZc#fidkdWxOYHwnPyd1blppbHNgWjA0S3VzXDdBbTFNVlJzfDVRQVQ2dVdBTnJTSH1QMGs2dHRsanJMbkY0PTxKbUtRaWowT2NwMGM8RlVBbGRqSWo3UFYwcVdqR3F9N2BtM2ZTPXc1Z3dQXGc2NTVPYVVSQkM8bycpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl\n\n4. The payment reservation expires at: 2025-01-10T08:52:20.253Z (about 30 minutes from now)\n\nTo complete the purchase, please follow these steps:\n1. Click on the checkout URL provided above.\n2. You will be redirected to a secure Stripe payment page.\n3. Enter your credit card details and complete the payment process.\n4. Once the payment is successful, the domain will be registered to you.\n\nMake sure to complete the payment before the expiration time to secure your domain. If you have any issues with the payment process or need any further assistance, please let me know.", 'type': 'text'}]`
- model: `claude-3-5-sonnet-20240620`
- role: `assistant`
- stop_reason: `end_turn`
- stop_sequence: `None`
- type: `message`
- usage:
  `{'cache_creation_input_tokens': 0, 'cache_read_input_tokens': 0, 'input_tokens': 4495, 'output_tokens': 532}`

</details>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sherlock_domains-0.0.5.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sherlock_domains-0.0.5-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file sherlock_domains-0.0.5.tar.gz.

File metadata

  • Download URL: sherlock_domains-0.0.5.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.10

File hashes

Hashes for sherlock_domains-0.0.5.tar.gz
Algorithm Hash digest
SHA256 e4abbefa7d0b0695e82110d631f635fd0280e56e5fc156995832822b8388e3c7
MD5 a852f5b2c95d6bbd000c66b34e6edeca
BLAKE2b-256 f9b415a68e294803a71c75c173cf35af2a09015af295662ba541aeec4c36d2c2

See more details on using hashes here.

File details

Details for the file sherlock_domains-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for sherlock_domains-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e0b42e5763d04ac7f2be2d4199bffa3ce18451648c7d01cb228728566d43f30a
MD5 a40c1876d07f9e00050a02acbfa83bce
BLAKE2b-256 56aa11fe7e38ced65afc6e9b32f72428f366a863c13b98adac7dc0edf711794f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page