Skip to content

Instantly share code, notes, and snippets.

@teroka
Created November 8, 2014 19:38
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save teroka/0720274b87b77fe7171f to your computer and use it in GitHub Desktop.
Save teroka/0720274b87b77fe7171f to your computer and use it in GitHub Desktop.
Dell API: Warranty Information
#!/usr/bin/env python
# Quick script to check your Dell asset's warranty status
# Just drop your service tag as parameters for the script and go.
import sys
import requests
APIKEY = 'd676cf6e1e0ceb8fd14e8cb69acd812d'
URL = 'https://api.dell.com/support/v2/assetinfo/warranty/tags.json?svctags={0}&apikey=' + APIKEY
def get_warr_from_dell(svctag):
res = requests.get(URL.format(svctag))
if res.status_code != 200:
sys.stderr.write('[%s] Caught %i as the response code.\n' % (svctag, res.status_code))
sys.stderr.write('[%s] Unable to get details for given service tag.\n'
% svctag)
return False
fault = res.json['GetAssetWarrantyResponse']['GetAssetWarrantyResult']['Faults']
if fault is not None:
sys.stderr.write("[%s] Failed to find details. Sure it's a valid TAG?\n" % svctag )
return False
asset = res.json['GetAssetWarrantyResponse']['GetAssetWarrantyResult']['Response']['DellAsset']
model = asset['MachineDescription']
ent = asset['Warranties']['Warranty']
shipped = asset['ShipDate']
print 'Service Tag: ', svctag
print ' Model: ', model
print ' Shipped: ', shipped, '\n'
print '{0:<20} {1:>15}'.format(*('Warranty Ends','ServiceLevelDescription'))
for warr in [(d['EndDate'],d['ServiceLevelDescription']) for d in ent]:
print '{0:<20} {1:>15}'.format(*warr)
if __name__ == '__main__':
get_warr_from_dell(sys.argv[1])
sys.exit()
Copy link

ghost commented Apr 12, 2018

How to apply apiKey

@Ezerbeth
Copy link

Go to https://developer.dell.com/, create a key, and wait forever for them to approve it. I requested mine over 2 months ago, contacted them twice and got nothing. Dell is such a terrible company.

@sterlingmd17
Copy link

THANK YOU. Making me look like a genius for my workplace 👍

@ShortArrow
Copy link

I can't access "https://developer.dell.com/".
how can i break this situation?

NET::ERR_CERT_AUTHORITY_INVALID
Subject: developer.dell.com
Issuer: Dell Technologies Issuing CA 101
Expires on: 2021/08/21
Current date: 2020/01/14

@moirisca
Copy link

still on certificate problems, website cant be reached...
same for other sites like myconnect-emea.dell.com
they can make some good servers, but they have no fucking clue on to configure them... LOL

  • SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
  • Server certificate:
  •    subject: C=US; ST=Texas; L=Round Rock; O=Dell USA L.P.; OU=Information Technology; CN=developer.dell.com
    
  •    start date: 2019-08-21 19:37:31 GMT
    
  •    expire date: 2021-08-20 19:37:31 GMT
    
  •    issuer: C=US; ST=Texas; L=Round Rock; O=Dell Technologies; CN=Dell Technologies Issuing CA 101
    
  •    SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
    

@Gomesz785
Copy link

Gomesz785 commented Sep 30, 2021

Error:

 File "/tmp/sessions/042c070d24edcaf8/main.py", line 31
    print 'Service Tag:        ', svctag
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Service Tag:        ', svctag)?

I think replacing this at line 31-36

print 'Service Tag:        ', svctag
    print ' Model:             ', model
    print ' Shipped:           ', shipped, '\n'
    print '{0:<20} {1:>15}'.format(*('Warranty Ends','ServiceLevelDescription'))
    for warr in [(d['EndDate'],d['ServiceLevelDescription']) for d in ent]:
        print '{0:<20} {1:>15}'.format(*warr)

with

print ('Service Tag:        ', svctag)
    print (' Model:             ', model)
    print (' Shipped:           ', shipped, '\n')
    print ('{0:<20} {1:>15}'.format(*('Warranty Ends','ServiceLevelDescription')))
    for warr in [(d['EndDate'],d['ServiceLevelDescription']) for d in ent]:
        print ('{0:<20} {1:>15}'.format(*warr))

solves it.

After making the above change, errors:

Traceback (most recent call last):
  File "/tmp/sessions/4f653f3fe2c7cb5a/main.py", line 38, in <module>
    get_warr_from_dell(sys.argv[1])
IndexError: list index out of range

And I have no idea to fix the above...

I think/got to know that sys.argv[x] is something related of

  • cutting command line commands. like: python 3 -m -n is sys.argv[0] = python 3 sys.argv[1] = -n sys.argv[2] = -n

  • or getting info by lines like:

a
b
c

so sys.argv[0] = a sys.argv[1] = b sys.argv[2] = c

After thinking and by the use of add zero when you are stuck at programming.

I put instead of this at 39

get_warr_from_dell(sys.argv[1])

put this

get_warr_from_dell(sys.argv[0])
After the above I got loads of updates and errors:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/urllib3/connection.py", line 159, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3.8/site-packages/urllib3/util/connection.py", line 61, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 976, in _validate_conn
    conn.connect()
  File "/usr/lib/python3.8/site-packages/urllib3/connection.py", line 308, in connect
    conn = self._new_conn()
  File "/usr/lib/python3.8/site-packages/urllib3/connection.py", line 171, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fa83d980850>: Failed to establish a new connection: [Errno -3] Try again
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 724, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3.8/site-packages/urllib3/util/retry.py", line 439, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.dell.com', port=443): Max retries exceeded with url: /support/v2/assetinfo/detail/tags.json?svctags=main.py&apikey=d676cf6e1e0ceb8fd14e8cb69acd812d (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa83d980850>: Failed to establish a new connection: [Errno -3] Try again'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "main.py", line 36, in <module>
    get_parts(sys.argv[0])
  File "main.py", line 13, in get_parts
    res = requests.get(URL.format(svctag))
  File "/usr/lib/python3.8/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.dell.com', port=443): Max retries exceeded with url: /support/v2/assetinfo/detail/tags.json?svctags=main.py&apikey=d676cf6e1e0ceb8fd14e8cb69acd812d (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa83d980850>: Failed to establish a new connection: [Errno -3] Try again'))


** Process exited - Return Code: 1 **
Press Enter to exit terminal


`


@Gomesz785
Copy link

Gomesz785 commented Sep 30, 2021

@ShortArrow did you used this after the certification problems were fixed? and were you able to pull data by this script (use this)?

@Gomesz785
Copy link

@moirisca were you able to pull data by this script (use this)?

@ShortArrow
Copy link

@Gomesz785

@ShortArrow did you used this after the certification problems were fixed?

Thank you for mentioning. I tried it now and it succeeded.
I gave up and forgot for a long time.

@ShortArrow
Copy link

But I can't find a way to get the API KEY from https://developer.dell.com. Which document is it written in?

@Gomesz785
Copy link

Gomesz785 commented Oct 1, 2021

Thank you for mentioning. I tried it now and it succeeded.
I gave up and forgot for a long time.

@ShortArrow succeeded for a what level, what did you accomplished? any errors? 404s?

@Gomesz785
Copy link

Gomesz785 commented Oct 1, 2021

But I can't find a way to get the API KEY from https://developer.dell.com. Which document is it written in?

@ShortArrow Probably somewhere in the site. I am not sure about the document. I think API keys are generated one-by-one and you have to apply for them and not one string on some document. OR are you asking the document having instructions on how to get a API key?

There is a thing called TechDirect and I have post on https://what.thedailywtf.com waiting to be approved, I will post it here for ya.

Our friend moirisca's last activity, dunno if you want it :) .

@Gomesz785
Copy link

Gomesz785 commented Oct 1, 2021

THANK YOU. Making me look like a genius for my workplace +1

@sterlingmd17 were you able to pull data by this script (use this)?

@ShortArrow
Copy link

Thank you for mentioning. I tried it now and it succeeded.
I gave up and forgot for a long time.

@ShortArrow succeeded for a what level, what did you accomplished? any errors? 404s?

It means that I was able to log in to https://developer.dell.com/. I couldn't do it at that time, so I gave up and left it.

@Gomesz785
Copy link

Gomesz785 commented Oct 1, 2021

Thank you for mentioning. I tried it now and it succeeded.
I gave up and forgot for a long time.

@ShortArrow succeeded for a what level, what did you accomplished? any errors? 404s?

It means that I was able to log in to https://developer.dell.com/. I couldn't do it at that time, so I gave up and left it.

@ShortArrow So in 2021 you was able to:

I am asking how tried it now and it succeeded?
Are you saying that you couldn't get the data by using a correct service tag that time and 2021 but in 2021 you were finally able to login? Am I correct?

Also did you saw this?

@ShortArrow
Copy link

Thank you for mentioning. I tried it now and it succeeded.
I gave up and forgot for a long time.

@ShortArrow succeeded for a what level, what did you accomplished? any errors? 404s?

It means that I was able to log in to https://developer.dell.com/. I couldn't do it at that time, so I gave up and left it.

@ShortArrow So in 2021 you was able to:

I am asking how tried it now and it succeeded? Are you saying that you couldn't get the data by using a correct service tag that time and 2021 but in 2021 you were finally able to login? Am I correct?

Also did you saw this?

  1. Write password and email.
  2. A few digits code will be sent by email.
  3. Enter the code.
  4. Finish the login.

image

I couldn't do just this on 14 Jan 2020, Due to a server error.

@Gomesz785
Copy link

Gomesz785 commented Oct 2, 2021

Thank you for mentioning. I tried it now and it succeeded.
I gave up and forgot for a long time.

@ShortArrow succeeded for a what level, what did you accomplished? any errors? 404s?

It means that I was able to log in to https://developer.dell.com/. I couldn't do it at that time, so I gave up and left it.

@ShortArrow So in 2021 you was able to:

I am asking how tried it now and it succeeded? Are you saying that you couldn't get the data by using a correct service tag that time and 2021 but in 2021 you were finally able to login? Am I correct?
Also did you saw this?

  1. Write password and email.
  2. A few digits code will be sent by email.
  3. Enter the code.
  4. Finish the login.

image

I couldn't do just this on 14 Jan 2020, Due to a server error.

@ShortArrow

  1. And you couldn't get a API key?
  2. You used the script to its full usage?
  3. You understand the script?
  4. Isn't the key on the script work?
  5. Is the script correct?

@ShortArrow
Copy link

@Gomesz785

Ok I'll try it. please wait.

@ShortArrow
Copy link

@Gomesz785 Wow, unfortunately it failed. My test result is here.

The code is a bit modified from the one at the top of the thread. Added parentheses for print statements.

(dell) PS C:\Users\who\Documents\GitHub\dell-warranty> python .\dell_warranty.py 6G331Y2
[6G331Y2] Caught 404 as the response code.
[6G331Y2] Unable to get details for given service tag.
(dell) PS C:\Users\who\Documents\GitHub\dell-warranty> python .\dell_warranty.py 6g331y2
[6g331y2] Caught 404 as the response code.
[6g331y2] Unable to get details for given service tag.
(dell) PS C:\Users\who\Documents\GitHub\dell-warranty> conda list
# packages in environment at C:\tools\miniconda3\envs\dell:
#
# Name                    Version                   Build  Channel
black                     21.9b0                   pypi_0    pypi
ca-certificates           2021.7.5             haa95532_1
certifi                   2021.5.30        py39haa95532_0
charset-normalizer        2.0.6                    pypi_0    pypi
click                     8.0.1                    pypi_0    pypi
colorama                  0.4.4                    pypi_0    pypi
idna                      3.2                      pypi_0    pypi
mypy-extensions           0.4.3                    pypi_0    pypi
openssl                   1.1.1l               h2bbff1b_0
pathspec                  0.9.0                    pypi_0    pypi
pip                       21.2.4           py38haa95532_0
platformdirs              2.4.0                    pypi_0    pypi
python                    3.9.7                h6244533_1
regex                     2021.9.30                pypi_0    pypi
requests                  2.26.0                   pypi_0    pypi
setuptools                58.0.4           py39haa95532_0
sqlite                    3.36.0               h2bbff1b_0
tomli                     1.2.1                    pypi_0    pypi
typing-extensions         3.10.0.2                 pypi_0    pypi
tzdata                    2021a                h5d7bf9c_0
urllib3                   1.26.7                   pypi_0    pypi
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
wheel                     0.37.0             pyhd3eb1b0_1
wincertstore              0.2              py39haa95532_2
(dell) PS C:\Users\who\Documents\GitHub\dell-warranty>

For vscode debugging ,.vscode\launch.json settings are shown below.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "args": ["1111111"] // your service tag
        }
    ]
}

@robertjoodat
Copy link

Thank you!

@Gomesz785
Copy link

Thank you!

You were able to use this?

@AngeloD2022
Copy link

AngeloD2022 commented Jul 21, 2022

Go to https://developer.dell.com/, create a key, and wait forever for them to approve it. I requested mine over 2 months ago, contacted them twice and got nothing. Dell is such a terrible company.

I decrypted and released their API key in the QRL app for android and soon after, received a DMCA complaint, forcing me to privatize the repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment